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

Skip to content

Commit 9d5b716

Browse files
committed
Fixed bug in MaxNLocator by changing Locator.nonsingular().
svn path=/trunk/matplotlib/; revision=2149
1 parent 0acffed commit 9d5b716

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

CHANGELOG

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
2006-03-14 Added import of compatibility library for newer numpy
1+
2006-03-15 Fixed bug in MaxNLocator revealed by [email protected].
2+
The main change is that Locator.nonsingular now adjusts
3+
vmin and vmax if they are nearly the same, not just if
4+
they are equal. A new kwarg, "tiny", sets the threshold. -
5+
EF
6+
7+
2006-03-14 Added import of compatibility library for newer numpy
28
linear_algebra - TEO
39

410
2006-03-12 Extended "load" function to support individual columns and
5-
moved "load" and "save" into matplotlib.mlab so they can be
6-
used outside of pylab -- see examples/load_converter.py -
7-
JDH
11+
moved "load" and "save" into matplotlib.mlab so they can be
12+
used outside of pylab -- see examples/load_converter.py -
13+
JDH
814

915
2006-03-12 Added AutoDateFormatter and AutoDateLocator submitted
1016
by James Evans. Try the load_converter.py example for a
@@ -13,11 +19,11 @@
1319
2006-03-11 Added subprocess module from python-2.4 - DSD
1420

1521
2006-03-11 Fixed landscape orientation support with the usetex
16-
option. The backend_ps print_figure method was
22+
option. The backend_ps print_figure method was
1723
getting complicated, I added a _print_figure_tex
1824
method to maintain some degree of sanity - DSD
1925

20-
2006-03-11 Added "papertype" savefig kwarg for setting
26+
2006-03-11 Added "papertype" savefig kwarg for setting
2127
postscript papersizes. papertype and ps.papersize
2228
rc setting can also be set to "auto" to autoscale
2329
pagesizes - DSD
@@ -29,7 +35,7 @@
2935

3036
2006-03-07 Fixed bug in backend_ps related to C0-C6 papersizes,
3137
which were causing problems with postscript viewers.
32-
Supported page sizes include letter, legal, ledger,
38+
Supported page sizes include letter, legal, ledger,
3339
A0-A10, and B0-B10 - DSD
3440

3541
===============================================================

lib/matplotlib/ticker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,10 @@ def zoom(self, direction):
518518
step = 0.1*interval*direction
519519
self.viewInterval.set_bounds(vmin + step, vmax - step)
520520

521-
def nonsingular(self, vmin, vmax, expander = 0.001):
521+
def nonsingular(self, vmin, vmax, expander=0.001, tiny=1e-6):
522522
if vmax < vmin:
523523
vmin, vmax = vmax, vmin
524-
if vmin==vmax:
524+
if vmax - vmin < max(abs(vmin), abs(vmax)) * tiny:
525525
if vmin==0.0:
526526
vmin -= 1
527527
vmax += 1
@@ -729,9 +729,10 @@ def autoscale(self):
729729

730730
def scale_range(vmin, vmax, n = 1, threshold=100):
731731
dv = abs(vmax - vmin)
732-
if dv == 0:
733-
return 1.0, 0.0
734732
meanv = 0.5*(vmax+vmin)
733+
var = dv/max(abs(vmin), abs(vmax))
734+
if var < 1e-12:
735+
return 1.0, 0.0
735736
if abs(meanv)/dv < threshold:
736737
offset = 0
737738
elif meanv > 0:

0 commit comments

Comments
 (0)