marker plots

Hi Well if you do lineplots

    > # plot some lines x = [1,2,3] for i in range(...):
    > plot(x)

    > mpl changes the color of each line which doesn't happen in
    > the case of marker plots.

Actually something different is going on, but I had to grok through
matplotlib.axes._process_plot_var_args to figure it out.

The default color cycling happens when there is no string format
applied, and is independent of markers and lines. For example, the
following does not cycle either

for i in range(4):
   plot(rand(5), rand(5), '-')

because a format string is applied.

You can make markers cycle too w/o a form string by changing the rc
params so that the default makrer is not 'None'

  rcParams['lines.marker'] = 'o'
  rcParams['lines.linestyle'] = 'None'
  for i in range(4):
      plot(rand(5), rand(5))

Whether or not this is ideal behavior is debatable. But it is
probably good enough since it is easy enough to force plot to act like
you want by explicitly passing args, as you did. I think Niklas'
suggestion of explicitly passing the kwargs for marker, linestyle,
color, markerfacecolor and so on is a better approach than
constructing arcane format strings. It is more readable and more
flexible, because format strings limit you to a small set of colors
whereas the kwargs approach supports arbitrary color arguments.

JDH

Hi

1.)

Hmmm the approach described below cycles colors for
  
  rcParams['lines.marker'] = 'o'

but for

  rcParams['lines.marker'] = '+'

I get black markers all the time (no cycling).

2.)

I'm wondering if there is an 'elegant' way to force color cycling for
things like

  for i in range(...):
    plot(...,'+')

  for j in range(...):
    plot(...,'x')

or do I always have to set

  rcParams['lines.marker'] = <makrer>

cheers,
steve

John Hunter wrote:

···

"Steve" == Steve Schmerler <elcorto@...361...> writes:

    > Hi Well if you do lineplots

    > # plot some lines x = [1,2,3] for i in range(...):
    > plot(x)

    > mpl changes the color of each line which doesn't happen in
    > the case of marker plots.

Actually something different is going on, but I had to grok through
matplotlib.axes._process_plot_var_args to figure it out.

The default color cycling happens when there is no string format
applied, and is independent of markers and lines. For example, the
following does not cycle either

for i in range(4):
   plot(rand(5), rand(5), '-')

because a format string is applied.

You can make markers cycle too w/o a form string by changing the rc
params so that the default makrer is not 'None'

  rcParams['lines.marker'] = 'o'
  rcParams['lines.linestyle'] = 'None'
  for i in range(4):
      plot(rand(5), rand(5))

Whether or not this is ideal behavior is debatable. But it is
probably good enough since it is easy enough to force plot to act like
you want by explicitly passing args, as you did. I think Niklas'
suggestion of explicitly passing the kwargs for marker, linestyle,
color, markerfacecolor and so on is a better approach than
constructing arcane format strings. It is more readable and more
flexible, because format strings limit you to a small set of colors
whereas the kwargs approach supports arbitrary color arguments.

JDH