Skip to content

ScalarFormatter creates useless offsets by default #461

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

6 participants

@jalan
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
Matplotlib Developers 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
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
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
Matplotlib Developers member
@dmcdougall
Matplotlib Developers 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

useOffset should be set to False by default.

@untom
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
Matplotlib Developers member

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

@tacaswell tacaswell closed this Nov 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.