0
import matplotlib.pyplot as plt    
fig, ax = plt.subplots(figsize=(12,8))
for key in dct.keys():
    plt.plot(*zip(*dct.get(key)), label=key)
ax.set_xticks(range(0,24))
ax.grid(color='gray', linestyle='-', linewidth=0.5)
plt.xlabel('x')
plt.ylabel('y')
plt.title('title')
plt.legend(loc=0,fontsize='small')
fig.show()

I generate a matplotlib linechart in a for loop, getting a total of 20 lines (one for each item of my dictionary, which are lists). The problem is that, having 20 lines, the assigned colors are way too similar: it seems to me like, after 10 items, the color schemes repeats itself and the following 10 items are of the same colors.

How can I change the color scheme to have different enough colors?

sato
  • 768
  • 1
  • 9
  • 30
  • 20 is just a lot. Can you find any examples of charts that use 20 clearly distinguishable colours? – Thomas May 25 '18 at 13:46
  • ofc 20 is a lot, and ofc I don't demand 20 clearly distinguishable colors, but is there a way to avoid the recurrency of the color scheme? Having 2 'not perfectly distinguishable' colors is different from having 2 IDENTICAL colors. – sato May 25 '18 at 13:50
  • See something like this answer: https://stackoverflow.com/questions/34914324/use-colormaps-along-with-matplotlib-cycler basically, change the color cycler to the colors in a colormap with as many colors as you want. You might look at the `tab20` colormap as one option – tmdavison May 25 '18 at 13:58

0 Answers0