Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2013
Merged

Conversation

mineo
Copy link
Contributor

@mineo mineo commented Dec 2, 2013

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
Copy link
Member

pelson commented Dec 3, 2013

👍 - I'm in favour of this change.

@mdboom
Copy link
Member

mdboom commented Dec 3, 2013

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
Copy link
Member

efiring commented Dec 3, 2013

Good idea.

@WeatherGod
Copy link
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
Copy link
Member

efiring commented Dec 3, 2013

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
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
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
Copy link
Contributor Author

mineo commented Dec 4, 2013

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

@pelson
Copy link
Member

pelson commented Dec 5, 2013

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
Copy link
Contributor Author

mineo commented Dec 5, 2013

@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
Copy link
Member

pelson commented Dec 5, 2013

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