The best way to do this is to use a generator:
import matplotlib.pyplot as plt
import numpy as np
Method to create a generator from an iterable. It keeps the
current position of the iterable in memory. Each time the
next() method for the iterable is called, it will return the
next item. If there are no more items, it will cycle to the
for item in itertools.cycle(iterable):
colors = _ncycle((‘r’,‘g’,‘b’,‘c’,‘y’,‘m’,‘k’),1)
markers = _ncycle((‘o’,‘s’,‘v’),1)
n = 20
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(n):
x = np.arange(0,10)
y = np.sin(x)+i-n/2
c = colors.next()
if c == ‘r’:
marker = markers.next()
On Fri, Nov 5, 2010 at 8:29 AM, Neal Becker <ndbecker2@…287…> wrote:
How can I automatically cycle through distinctive line markers?
I want a semilog plot, composed of a number of lines. Each line should have
a different color and marker.
Cycling through the colors is automatic, but not the markers.
BTW, shouldn’t this behavior be the default? I would just like to say
markers=True and get this behavior.
The Next 800 Companies to Lead America’s Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
Matplotlib-users mailing list
B.Eng & Biosci, M.Eng Design