0

I have the following code:

filenames=sorted((glob.glob('G*_5.csv')))

cycol=cycle('bgrcmky').next

for fname in ((glob.glob('G*_5.csv'))):
    data=np.loadtxt(fname, delimiter=",")
    X=data[:,1]
    Y=data[:,0]
    n=fname.split('_')
    plt.plot(X,Y, c=cycol(), linestyle='--', label=n[0], linewidth=3.0 )

plt.title("Damage Patterns 5'")
plt.xlabel("Base")
plt.ylabel("%")
plt.legend(loc='upper right')
plt.xticks([1, 2, 3, 4, 5])
plt.ylim((0,50))
plt.show() 

Which gives the following output:

Output

which is fine but I have one problem with the colors since in the cycle('bgrcmky') I only specified seven colors. But I need ten different ones or more. I landed on this site matplotlib colors where different ways are stated to specify the color. So I tried some of those methods like:

cycol=cycle(["(0.1, 0.2, 0.5)", "(0.1, 0.2, 0.5, 0.3)"]).next

or

cycol=cycle(["xkcd:sky blue", "xkcd:orange"]).next

but these are not working. So is there any way to upgrade the method I used with the cycle to get more then seven colors?

Thanks in advance :)

JFS31
  • 518
  • 5
  • 13
  • Hey, I already looked at some of the answers you mentioned but at the moment I'am not smart enough to implement the code they used there into my example. – JFS31 Dec 22 '17 at 10:17
  • I closed this as a duplicate now because those answers show ways to achive different line colors with arbitrary number of colors. Now if you have a very specific problem, you may of course ask about it by making it clear how other answers have not helped and more importantly, provide a [mcve] of the issue. The above is not runnable. But if the question is edited accordingly, one may of course reopen it. – ImportanceOfBeingErnest Dec 22 '17 at 10:26
  • The last code example given in Joe Kington's answer of the duplicate is pretty straightforward to add to your code (adding two lines and removing a bit of your code) – DavidG Dec 22 '17 at 10:26
  • Ok, I will try it. Thank you. – JFS31 Dec 22 '17 at 10:27

0 Answers0