On Tue, Apr 24, 2012 at 12:21 AM, Tony Yu <tsy...@gmail.com> wrote: > > > On Mon, Apr 23, 2012 at 5:09 AM, jul tayon <jta...@gmail.com> wrote: >> >> Hello list >> >> matplotlib website says this mailing is the prefered way to report >> bug, so here I am : >> >> System : >> python ; 2.7.2+ >> matplotlib 1.1.0 >> ubuntu TLS amd64 >> matplotlib Backend : TkAgg >> >> >> How to reproduce (on my pf) >> Code Snippet : >> >> ######CODE >> >> import matplotlib >> import matplotlib.pyplot as p >> import random >> y = random.randint(0,10000000) >> p.plot( [ int( y * ( 1 - 0.0006)) , y]) >> p.show() >> >> ######ENDCODE >> >> Exected Result : >> https://github.com/jul/pypi-stat/blob/master/why.png >> >> Cause ? >> >> It stinks something like a rounding error on the float. >> If it also happens in Qt/Gtk backend it might be a matplotlib bug, if >> it is only in Tk then it is either a Tk or a TkAgg bug. >> >> Cheers, >> -- >> Jul > > > Sorry, I'm not clear on what the bug is. Is the picture you link to the > *expected* result or the result from *executing* the code snippet. There are > some inconsistencies between the pic and the code (legend, time on xaxis, 3 > point in pic, title), so it's a bit unclear what you're referring to. > > If you're talking about the offset value added to the y-axis, it's actually > not a bug; it's a feature (usually that's a joke, but in this case, I'm > serious). > > This feature is useful when you have large numbers that vary over small > ranges. Maybe it's not so bad in your example, but for larger numbers with > smaller ranges (see code snippet below), it's quite helpful. I thought there > was an rc parameter to tweak the value for using offsets, but I can't seem > to find it. Below I create a custom tick formatter and turn offsets. There > may be a better way to do this.
With recent mpl you can use the ticklabel_format pyplot function or axes method. Eric > > If this isn't the bug you were suggesting, please clarify. > > Best, > -Tony > > #~~~~~ > import matplotlib.pyplot as plt > > fig, ax = plt.subplots() > # or `ax = plt.gca()` for older versions of matplotlib > > y = 1e9 > ax.plot([y, y+1]) > ax.yaxis.set_major_formatter(plt.ScalarFormatter(useOffset=False)) > > plt.show() > #~~~~~ > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users