"pyplot.plot_date()" is not changing the line colors using "color_cycle" #2148

Closed
saullocastro opened this Issue Jun 22, 2013 · 7 comments

Comments

Projects
None yet
5 participants

Please, check this question in Stackoverflow:
http://stackoverflow.com/q/17250392/832621
which motivated this bug report.

The OP identified that when trying to plot using plot_date() the colors are not changed accordingly to the color_cycle specified. Actually they are not changing at all.
With plot() it works perfectly.
I tried to change the colors from plot_date() using:
plt.rc('axes', **{'color_cycle':['r', 'g']})
plt.rcParams['axes.color_cycle']=['r','g']
and
setting the matplotlibrc file to the local folder with axes.color_cycle : r, g.

they all did not work.

thank you very much and congratulations for the great package which Matploblib already is!
Saullo Castro

Owner

tacaswell commented Jun 23, 2013

This isn't a bug, but a design choice. There is a default argument in both plt.date_plot and axes.date_plot that sets the format to bo.

See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py#L4145 and https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/pyplot.py#L2997

@dmcdougall dmcdougall closed this Jun 23, 2013

Thank you all for the responses... It is ok that data_plot() sets the format to bo but why the user cannot change it?

Member

WeatherGod commented Jun 24, 2013

Probably wasn't a conscious design choice. I move to switch it over to
None, so that the color-cycling mechanism can happen.

Are you going to switch it to None for the next version? That would be great! In matplotlib 1.2.1 is there a way to switch it to None?

Owner

tacaswell commented Jun 24, 2013

@saullocastro Call it as

plot_data(..., fmt=None)

@tacaswell Thank you! For me it worked doing plot_date(..., fmt='')

mineo added a commit to mineo/matplotlib that referenced this issue Dec 2, 2013

plot_date: Set the default fmt to 'o'
Different to just plot() plot_date() has a default plot format string
which makes it necessary to *unset* the default one when drawing
multiple sequences of dates in a figure to get a working color cycling.
It also was not exactly clear that Axes.set_color_cycle was setting the
color cycle for every plot command except for plot_date ones.

It was of course possible to simply unset it after reading the
documentation but that's not the path of least suprise.

The default fmt of 'o' will keep the markers by default (which makes
sense for dates) but allows color cycling to happen.

This is related to issue #2148

mineo added a commit to mineo/matplotlib that referenced this issue Dec 5, 2013

plot_date: Set the default fmt to 'o'
Different to just plot() plot_date() has a default plot format string
which makes it necessary to *unset* the default one when drawing
multiple sequences of dates in a figure to get a working color cycling.
It also was not exactly clear that Axes.set_color_cycle was setting the
color cycle for every plot command except for plot_date ones.

It was of course possible to simply unset it after reading the
documentation but that's not the path of least suprise.

The default fmt of 'o' will keep the markers by default (which makes
sense for dates) but allows color cycling to happen.

This is related to issue #2148

fmt is for the shape, what can we use for size.
I tried with m or ms or s but all throw error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment