I've spent too many hours trying to figure out how to use pre-made colormap or color palette for my plots in Python. How does one change the colormap for his plots? Is there some simple way of doing it?
I did try to use function such as
plt.set_cmap('Set1')
but I'm using it wrong I guess. Here's the code I want the palette to be changed in:
import matplotlib.pyplot as plt
for i in range(10):
plt.plot([0,1],[i,i])
plt.show()
I made workaround for now, but I would be pleased if someone came up with a real solution.
import matplotlib.pyplot as plt
colors = ["#1f77b4","#ff7f0e","#2ca02c","#f61600","#7834a9",
"#17becf","#684427","#fa5deb","#17becf","#17becf"]
for i in range(10):
plot.plt([0,1],[i,i], color = colors[i])
plt.show()
The task is simple, change the default color palette to one of these qualitative ones (e.g. 'Set1', 'tab20'): https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html