automatically choose line markers/styles?

Alan G Isaac wrote:

···

On Thu, 14 Feb 2008, Neal Becker apparently wrote:

Can I get nice default line styles and markers,
automatically set up with matching legend? Automatically
chosen? I don't want to have to go through and manually
choose each marker and line style.

Well, you have to ask for a legend, but everything else
default looks good to me. What is an example where you do
not like the default behavior?

Are you trying to make a bunch of figures look alike?

IIUC, in order to have each line with distinct line style, I have to
explicitly set the line style. I want pylab to just choose them, just as
it does for colors.

Well, pylab does choose: it varies color and not the dash
pattern in order to have distinct lines.

I think what you are wanting is something like the
following: have pylab/pyplot cycle automatically through
a set of preset Line2D property combinations, when an axes
plots multiple lines.

I think the answer is: this is not available in the
form you want. (Indeed, it is hard for me to imagine
agreement on "nice" choices for multiple properties.)

Of course you can do something like this::

    from itertools import cycle

    mystyles = ['r+-', 'b.--', 'go-.'] #etc
    ax1styles = cycle( mystyles )

    for x,y in data:
        ax1.plot(x, y, ax1styles.next())

Cheers,
Alan Isaac

···

On Tue, 19 Feb 2008, Neal Becker apparently wrote:

IIUC, in order to have each line with distinct line style, I have to
explicitly set the line style. I want pylab to just choose them, just as
it does for colors.

You can also cycle through the list matplotlib uses

  import matplotlib.lines as lines

  # filled markers
  fmarkers = lines.Line2D.filled_markers

  # all markers
  markers = lines.Line2D.markers.keys()

but this is not ideal, since lines.Line2D.markers is a dictionary and
the keys will come back un-ordered. Noone has every asked for
auto-marker cycling before, but it might be a good idea and wouldn't
be too hard to add.

JDH

···

On Feb 19, 2008 9:13 AM, Alan G Isaac <aisaac@...310...> wrote:

Of course you can do something like this::

    from itertools import cycle

    mystyles = ['r+-', 'b.--', 'go-.'] #etc
    ax1styles = cycle( mystyles )

Just an idea: Maybe you could also auto cycle between dash types if only the colour and not the dash type is specified in a plot command. The gnuplot default would be one model, or the predefined patterns in CorelDraw or Inkscape etc. Personally I don't see this as a high priority though.

Gary R.