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
Aguy
  • 7,851
  • 5
  • 31
  • 58

1 Answers1

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)
Community
  • 1
  • 1
Aguy
  • 7,851
  • 5
  • 31
  • 58