Skip to content

[WIP] Proposed improvement in default log formatting #4730

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

Closed
wants to merge 1 commit into from

Conversation

astrofrog
Copy link
Contributor

This is a proposed change in defaults for the upcoming 2.0 release, in response to @tacaswell's email on the matplotlib list (and this is by no means a finished PR).

When making log plots, having 10^0 and 10^1 instead of 1 and 10 looks unpolished and I often encounter users that comment (negatively) on it:

logs_before

I would like to propose that we fix this properly and make it so that the default log formatter uses 0.1, 1, and 10 in instead of 10^-1, 10^0, and 10^1. The current PR gives:

logs

The PR here is clearly not the final answer - at the moment you can see that the baseline for the labels is wrong on the x-axis for the 0.1, 1, and 10 values due to the lack of exponent. Presumably we could align the labels using the bottom of the labels instead of the top. Or we could an empty exponent. But for the y-axis, this looks a lot nicer. This would also need tests, etc.

Any thoughts about this?

@Tillsten
Copy link
Contributor

Actual i disgree on that, i like the first graph more . Note a option in LogFormattter when to use scientific notation would be wonderful, (e.g. min_exponent=2 for the behavior proposed.).

@tacaswell tacaswell added this to the Color overhaul milestone Jul 17, 2015
@endolith
Copy link
Contributor

My first reaction was "no", but then I looked at it again and I like it. I can't find any examples of other people doing this, though.

@efiring
Copy link
Member

efiring commented Jul 18, 2015

I agree with @Tillsten's suggestion that this needs to be implemented as an option, not as the sole formatting method.

@astrofrog
Copy link
Contributor Author

I'd be fine with having it as an option, but what about exposing that option at the level of set_xscale/set_yscale too? (so that users to have to go an import the logformatter class etc.?)

@tacaswell
Copy link
Member

That probably makes sense to allow formatter options to pass through, but
we should then also post through locator options.

It might be simpler to just document how to mutate the locator/formatter
after the fact.

It feels like we have a lot of inconsistent apis due to requests like this
which make perfect sense in isolation, but lead to very complicated, hard
to use code when they all get stacked.

On Sun, Jul 19, 2015, 3:08 AM Thomas Robitaille notifications@github.com
wrote:

I'd be fine with having it as an option, but what about exposing that
option at the level of set_xscale/set_yscale too? (so that users to have
to go an import the logformatter class etc.?)


Reply to this email directly or view it on GitHub
#4730 (comment)
.

@keflavich
Copy link
Contributor

👍 for having this as an option. Whichever API makes it into the examples gallery is the only one I'm every likely to use, unless it shows up on a stackoverflow question.

@zblz
Copy link
Member

zblz commented Jul 29, 2015

Another issue related to this one I usually encounter is with axis that have limits of the order of a decade or two. For these, only a couple of labels will be shown. A combination of

ax.xaxis.set_minor_locator(ticker.LogLocator(subs=[1,2,5])
ax.xaxis.set_major_formatter(ticker.NullFormatter())
ax.xaxis.set_minor_formatter(ticker.LogFormatter(labelOnlyBase=False))

will add labels on 1, 2, 5 multiples of the base. However, this does not work with ticker.LogFormatterMathtext, which will show 10^{4.30} instead of 2\times10^{4}, and you lose all the other minor ticks.

Now that I reread it, this might need to go in a separate issue. Do you think it's worth to do it for the default change?

@tacaswell
Copy link
Member

Please make a separate issue.

On Wed, Jul 29, 2015, 7:49 AM Victor Zabalza notifications@github.com
wrote:

Another issue related to this one I usually encounter is with axis that
have limits of the order of a decade or two. For these, only a couple of
labels will be shown. A combination of

ax.xaxis.set_minor_locator(ticker.LogLocator(subs=[1,2,5])
ax.xaxis.set_major_formatter(ticker.NullFormatter())
ax.xaxis.set_minor_formatter(ticker.LogFormatter(labelOnlyBase=False))

will add labels on 1, 2, 5 multiples of the base. However, this does not
work with ticker.LogFormatterMathtext, which will show 10^{4.30} instead
of 2\times10^{4}, and you lose all the other minor ticks.

Now that I reread it, this might need to go in a separate issue. Do you
think it's worth to do it for the default change?


Reply to this email directly or view it on GitHub
#4730 (comment)
.

@zblz
Copy link
Member

zblz commented Oct 1, 2015

Regarding how to make this an option, I think it would be worth including it in rcParams: it is something a user will likely always want on or off because of personal preference, but rarely on a per-plot basis.

@mdboom mdboom modified the milestones: Color overhaul, next major release (2.0) Oct 8, 2015
@mdboom
Copy link
Member

mdboom commented Nov 9, 2015

We plan to make this the new default for 2.0 (which means it will grow an rcParam so that classic mode will work). But we'll need to fix the baseline issue first.

@Tillsten
Copy link
Contributor

Tillsten commented Nov 9, 2015

@mdboom Please don't, I still don't see why -1, 0, 1 should be special powers in a log plot: In symlog-plots the different notations are often use to mark the linear and the log-part separately. I also never heard anybody complain about 10^0 or 10^1.

@zblz zblz mentioned this pull request Jan 31, 2016
@efiring
Copy link
Member

efiring commented Feb 8, 2016

@astrofrog, @tacaswell and I have decided that this would be a nice option, but given the differences of opinion about making it a default, we will not do so in 2.0. Would you augment this PR, please, to provide rcParams control?

@efiring efiring modified the milestones: 2.1 (next point release), 2.0 (style change major release) Feb 8, 2016
@zblz
Copy link
Member

zblz commented Jul 25, 2016

@astrofrog: Do you have time to finish this with rcParams control? I am finishing up #5161, and this PR would be a nice companion. I can take over if you don't have the time.

@astrofrog
Copy link
Contributor Author

@zblz - it would be great if you could take over and just cherry-pick my commits - thanks!

@zblz
Copy link
Member

zblz commented Jul 26, 2016

Closing as work is continued in #6834

@zblz zblz closed this Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants