Skip to content
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

ScalarFormatter creates useless offsets by default #461

Closed
jalan opened this issue Sep 8, 2011 · 8 comments
Closed

ScalarFormatter creates useless offsets by default #461

jalan opened this issue Sep 8, 2011 · 8 comments

Comments

@jalan
Copy link

jalan commented Sep 8, 2011

Here is a minimal example of this issue in action. Take a look at the offsets we get by default: http://i.imgur.com/OdLqD.png

#!/usr/bin/python

import matplotlib.pyplot

# Sample data
x = [1, 2, 3, 4]
y1 = [1119, 1125, 1122, 1118]
y2 = [0.002101, 0.002104, 0.002103, 0.002102]

# Plot the data
figure_1 = matplotlib.pyplot.figure()
axes_1 = figure_1.add_subplot(211) 
axes_1.plot(x, y1)
axes_2 = figure_1.add_subplot(212)
axes_2.plot(x, y2)

# View
matplotlib.pyplot.show()

These offsets are less than helpful. For now I just constantly use

my_axes.ticklabel_format(useOffset=False)
@WeatherGod
Copy link
Member

Agreed, I have never quite liked the offset chosen by the formatter. A while back, I attempted to come up with an algorithm that tried to determine the common significant digits of a set of values, but there were several cases where it failed to do what was desired. Maybe I should look at that code again and see if I could get it working.

@jalan
Copy link
Author

jalan commented Sep 8, 2011

Perhaps this feature should be off by default, at least until the algorithm is improved? I admit it could be useful occasionally, but right now it can produce some rather surprising results!

@jalan
Copy link
Author

jalan commented Sep 10, 2011

Another problem: a y-axis offset showed up by default again, but this time I am using the DateFormatter. No problem, I'll turn it off as usual:

axes_1 = figure_1.add_subplot(111)
axes_1.plot_date(x, y, xdate=True)
axes_1.ticklabel_format(useOffset=False)
AttributeError: This method only works with the ScalarFormatter.

Can't turn it off! But it we put the commands in another order, can we trick it into giving us what we want?:

axes_1 = figure_1.add_subplot(111)
axes_1.ticklabel_format(useOffset=False)
axes_1.plot_date(x, y, xdate=True)

No error, and I get what I want!

@WeatherGod
Copy link
Member

Not exactly a bug. ticklabel_format() will, by default, set the attribute
for both the x and y axes. Since we already know that the offset is on the
y-axis, then use the call for just the y-axis:

axes_1.ticklabel_format(useOffset=False, axis='y')

That would work without error.

@dmcdougall
Copy link
Member

I've been looking into this a little bit. It doesn't matter how many common significant figures there are, if the number of them gets much bigger than, say, two the offset becomes unreadable.

How about always using an offset in normalised notation?

@jobevers
Copy link

useOffset should be set to False by default.

@untom
Copy link

untom commented Nov 4, 2013

Hi!

I recently stumbled over this issue, it took me quite some time to figure out what was wrong with my plots, because I didn't interpret my axis correctly. I find this behavior very confusing. The fact that everyone in this issue seems to agree, yet no patch has been presented is a bit weird.

@tacaswell
Copy link
Member

Closing because #2401 which provides an rcParam for the value of useoffset has been merged

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

No branches or pull requests

6 participants