Skip to content

plot_date: Set the default fmt to 'o' - #2641

Merged
pelson merged 1 commit into
matplotlib:masterfrom
mineo:plot-date-fmt
Dec 5, 2013
Merged

pelson merged 1 commit into
matplotlib:masterfrom
mineo:plot-date-fmt

Conversation

@mineo

@mineo mineo commented Dec 2, 2013

Copy link
Copy Markdown
Contributor

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

(Here ends the commit message)

I'm the one who asked the question on SO that's linked to in issue #2148 and I just had to give this a try with a pull request because I think the discussion on the ticket was really short. Imho, setting the default format to just 'o' which keeps the markers but allows color cycling to happen is a reasonable compromise.

@pelson

pelson commented Dec 3, 2013

Copy link
Copy Markdown
Member

👍 - I'm in favour of this change.

@mdboom

mdboom commented Dec 3, 2013

Copy link
Copy Markdown
Member

This makes sense to me as well. It will need a changelog entry, however, since it is (of course) a change of default behavior.

@efiring

efiring commented Dec 3, 2013

Copy link
Copy Markdown
Member

Good idea.

@WeatherGod

Copy link
Copy Markdown
Member

I am still iffy on this. I understand that this is a compromise, and it
certainly isn't a bad one. Ultimately, though, it goes backwards against
our push to eliminate non-None defaults for keyword arguments. I won't
block this change, but I just wanted to warn that this will likely cause
other headaches in the future.

@efiring

efiring commented Dec 3, 2013

Copy link
Copy Markdown
Member

The implementation could easily be changed to use None. I don't see that it matters either way. What am I missing? Also, do we really want to eliminate non-None kwargs? For plot_date, for example, I don't see any possible advantage to using None for the xdate and ydate kwargs. The advantage of None is that it facilitates using rcParams for defaults, correct? Do you want plot_date.xdate and plot_date.ydate rcParams?

@tacaswell

Copy link
Copy Markdown
Member

I don't see how this change (from 'bo' -> 'o') will cause more headaches than leaving the status quo.

I think the main advantage None default values is that you can easily wrap plotting functions in and pass in kwargs in optional transparent way without having to copy the default values into your own function signature and without having to use **kwargs.

@WeatherGod

Copy link
Copy Markdown
Member

Ok, it pays to actually look at a diff rather than working from memory. I forgot that the plot_date()'s fmt is currently non-None anyway, so this is actually a step in the right direction, and I would be really happy when the default for fmt can be None so that other behavior can be enabled by default such as marker cycling (which has been something I have tinkered with for a while, but have been stymied by non-None defaults). The reason why we want to avoid non-None default values is that it is impossible to distinguish between a user explicitly stating that they want that default value, or that they don't care. This is where the idea of using None to mean "do the default thing" came to being. Obviously, kwargs such as xdate and ydate don't make sense to have anything more than just default values, so having a None for those likely superfluous.

Btw, the pyplot.py needs to be updated as well.

@mineo

mineo commented Dec 4, 2013

Copy link
Copy Markdown
Contributor Author

I've now updated api_changes.rst (which is hopefulle the right place for this) and rerun boilerplate.py.

@pelson

pelson commented Dec 5, 2013

Copy link
Copy Markdown
Member

Sorry @mineo but this wont merge cleanly. Would you mind squashing your commits, then rebasing?

git rebase -i HEAD~3

See http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html for details

Then

git fetch upstream
git rebase upstream/master

Thanks!

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 matplotlib#2148
@mineo

mineo commented Dec 5, 2013

Copy link
Copy Markdown
Contributor Author

@pelson
Done and git push -fed.

pelson added a commit that referenced this pull request Dec 5, 2013
plot_date: Set the default fmt to 'o'
@pelson
pelson merged commit 0ea037d into matplotlib:master Dec 5, 2013
@pelson

pelson commented Dec 5, 2013

Copy link
Copy Markdown
Member

Merged. Thanks @mineo

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants