Hi,
The best way to do this is to use a generator:
import itertools
import matplotlib.pyplot as plt
import numpy as np
def _ncycle(iterable,n):
"""
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
first item.
"""
for item in itertools.cycle(iterable):
yield item
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()
ax.plot(x,y,c=c,marker=marker)
plt.show()
On Fri, Nov 5, 2010 at 8:29 AM, Neal Becker <ndbeck...@gmail.com> 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!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Aman Thakral
B.Eng & Biosci, M.Eng Design
------------------------------------------------------------------------------
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!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users