How to get default blue colour of matplotlib.pyplot.scatter?

The default colour cycle was changed in matplotlib version 2 as shown in the docs.

Therefore, to plot the “new” default blue you can do 2 things:

fig, ax = plt.subplots()

ax.scatter(-1, 1)
ax.text(-0.9, 1, 'Default blue')

ax.scatter(1, 1, c="#1f77b4")
ax.text(1.1, 1, 'Using hex value')

ax.scatter(0, 0.5, c="C0")
ax.text(0.1, 0.5, 'Using "C0" notation')

ax.set_xlim(-2, 3)
ax.set_ylim(-1,2)
plt.show()

Which gives:

enter image description here

Alternatively you can change the colour cycle back to what it was:

import matplotlib as mpl
from cycler import cycler

mpl.rcParams['axes.prop_cycle'] = cycler(color="bgrcmyk")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)