On Tue, Apr 14, 2009 at 8:50 AM, John Hunter <jdh2...@gmail.com> wrote:

> On Tue, Apr 14, 2009 at 8:09 AM, Chaitanya Krishna <icym...@gmail.com>
> wrote:
> > Hello all,
> >
> > Usually when I plot two or more lines, the color of the lines change.
> > Is it possible to change this default behavior so that when I plot two
> > or more lines, the symbols change and not the color.
> >
> > This would be useful if someone is trying to make plots in black and
> > white so that the symbols change instead of line colors.
>
> You can do this with a little manual intervention -- below is a script
> which cycles through all of mpl's line markers.
>
>    import numpy as np
>    import matplotlib.lines as lines
>    import matplotlib.pyplot as plt
>
>    markers = list(lines.Line2D.markers.keys())
>    markers.sort()
>    N = len(markers)
>
>    fig = plt.figure()
>    ax = fig.add_subplot(111)
>    x = np.arange(20)
>    for i in range(50):
>        marker = markers[i%N]
>        print marker
>        y = i*x
>        ax.plot(x, y, marker=marker, linestyle='', mfc='blue')
>
>    plt.show()
>
> You could do a similar trick with linestyles using the
> lines.Line2D.lineStyles and lines.Line2D.drawStyles dictionaries
> (these map the symbols to the internal Line2D function we use to draw
> the symbols).  See also
>
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/line_styles.html


Also, you can use itertools.cycle to loop over a set of markers probably a
bit more cleanly than the example:

markers = itertools.cycle(lines.Line2D.markers.keys())
marker = markers.next()

Ryan


-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to