The default axis colour cycle in Matplotlib 2.0 is called tab10
:
I want to use a different qualitative colour cycle, such as tab20c
:
I have used this code to change the default axis colour cycle:
import matplotlib.pyplot as plt
from cycler import cycler
c = plt.get_cmap('tab20c').colors
plt.rcParams['axes.prop_cycle'] = cycler(color=c)
This looks pretty dirty to me. Is there a better way?
The default interactive figure background color has changed from grey to white, which matches the default background color used when saving. in your matplotlibrc file.
plt. style. use('default') worked for me. As I understand this, it tells matplotlib to switch back to its default style mode.
The default color of a scatter point is blue. To get the default blue color of matplotlib scatter point, we can annotate them using annotate() method.
As said in the comments, it's not clear what "better" would mean. So I can think of two different ways in addition to the one from the question, which works perfectly fine.
Just to show a different way of setting the color cycler: Seaborn has a function set_palette
, which does essentially set the matplotlib color cycle. You could use it like
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_palette("tab20c",plt.cm.tab20c.N )
If you want the cycler for each axes individually, you may use ax.set_prop_cycle
for an axes ax
.
import matplotlib.pyplot as plt
from cycler import cycler
fig, ax = plt.subplots()
ax.set_prop_cycle(cycler(color=plt.get_cmap('tab20c').colors))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With