In my application, I am creating a second axes using
> pylab's twinx and plot various lines on both axes. I'd
> like to take advantage of the automatic change of the line
> color that happens when using the plot()
> command. Unfortunately, this is done only within one axes
> i.e. when plotting on the other axes, the first line color
> is used again. This results in multiple lines that have
> the some color.
> Is there a smart way to make Matplotlib use the next color
> in sequence for the first line on a new axes?
There is no way to do this automatically w/o changing the internals of
the line cycle code. At present each Axes gets its own color cycle
counter, and twinx creates a new axes instance with a shared cycle.
You could hack the twinx code to share the counter
ax1._get_lines.count = ax2._get_lines.count
but this would break after a cla in the current implementation since
the _get_lines_count attr is reset there. The relevant code is in
Axes.cla, axes._process_plot_var_args and pylab.twinx if you want to
try and fix this in a sensible way and submit a patch.
JDH