5

I know this question was asked a dozen times but I need help in my specific example. I just don't know why it's not working.

In the end i want 150 different lines but for now I just want to test it with 10 lines.

The aim is to iterate through the colour map and my code looks like this:

import matplotlib.pyplot as plt

jet= plt.get_cmap('jet')
colors = iter(jet(np.linspace(0,1,10)))
for k in range(0,10):
    plt.plot(u_ordered[0*k:42*(k+1)], T_ordered[0*k:42*(k+1)], 'o',
color=next(colors))


plt.xscale('log')
plt.ylabel('T [K]')
plt.xlabel('log u [KJ/g]')
plt.title('T - U (at const. Rho) Plot')
plt.legend(loc="lower right")
plt.savefig('T_u_const_rho_Plot1.pdf')
plt.show()

I keep on getting this for all the 150 lines: enter image description here

1 Answer 1

11

In each iteration of your loop, you are plotting over everything that you have already plotted. Try replacing the plotting part with

plt.plot(u_ordered[42*k:42*(k+1)], T_ordered[42*k:42*(k+1)], 'o', color=next(colors))
Sign up to request clarification or add additional context in comments.

4 Comments

That's exactly it! Thanks a lot! :)
what did you change ?
@MarineGalantin: 42*k instead of 0.
I see thank you for the anwer, couldn't figure it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.