1

A simple quick question: I am plotting stuff into a figure. Line colors are cycling with each new plot command.

Is there a way to tell matplotlib to "reset" the style and set it back to the first color, continuing to cycle from the start?

Something like:

plt.plot(np.random.rand(10,))   # -> produces line with color #0000ff
plt.plot(np.random.rand(10,))   # -> produces line with color #008000
plt.plot(np.random.rand(10,))   # -> produces line with color #ff0000
# now what I wish for
plt.colors_reset_or_something_like_that()
# and then colors are back to start
plt.plot(np.random.rand(10,))   # -> produces line with color #0000ff
plt.plot(np.random.rand(10,))   # -> produces line with color #008000
0

1 Answer 1

3

Thanks for the quick pointer, @Mathias. The answer is clearly stated at Reset color cycle in Matplotlib

The line I needed is:

plt.gca().set_prop_cycle(None)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.