Hi,
I find it difficult to read the values of an axis when the offset is active.
The problem is that many time I find myself doing calculations like
-1.2345e2-0.048 to find out the value of the tick. I send enclosed a patch
and a test file to, in my opinion, improve the readability of the ticks with
an offset.
Cheers,
Francisco
Index: lib/matplotlib/ticker.py
===================================================================
--- lib/matplotlib/ticker.py (revision 7967)
+++ lib/matplotlib/ticker.py (working copy)
@@ -425,9 +425,17 @@
if np.absolute(ave_oom-range_oom) >= 3: # four sig-figs
if ave_loc < 0:
- self.offset = math.ceil(np.max(locs)/10**range_oom)*10**range_oom
+ temp = np.max(locs)/10**(range_oom + 1)
+ temp = math.trunc(temp) - temp
+ if temp + range/10**(range_oom + 1) >= 1: # Next sig-fig changes
+ range_oom += 1
+ self.offset = math.ceil(np.max(locs)/10**(range_oom+1))*10**(range_oom+1)
else:
- self.offset = math.floor(np.min(locs)/10**(range_oom))*10**(range_oom)
+ temp = np.min(locs)/10**(range_oom + 1)
+ temp = temp - math.trunc(temp)
+ if temp + range/10**(range_oom + 1) >= 1: # Next sig-fig changes
+ range_oom += 1
+ self.offset = math.floor(np.min(locs)/10**(range_oom+1))*10**(range_oom+1)
else: self.offset = 0
def _set_orderOfMagnitude(self,range):
from matplotlib.pyplot import *
figure()
subplot(241)
a = np.random.random((100,100))
a *= 20 # Order of magnitude of range
a += 1234567 # loc.min()
imshow(a)
colorbar()
title('> 0 OOM 1, case + 1')
subplot(242)
a = -a
imshow(a)
colorbar()
title('< 0 OOM 1, case + 1')
subplot(243)
a = np.random.random((100,100))
a *= 34 # Order of magnitude of range
a += 1234567 # loc.min()
imshow(a)
colorbar()
title('> 0 OOM 1, case + 2')
subplot(244)
a = -a
imshow(a)
colorbar()
title('< 0 OOM 1, case + 2')
subplot(245)
a = np.random.random((100,100))
a *= 20e-3
a += 123.4567
imshow(a)
colorbar()
title('> 0 OOM -2, case + 1')
subplot(246)
a = -a
imshow(a)
colorbar()
title('< 0 OOM -2, case + 1')
subplot(247)
a = np.random.random((100,100))
a *= 54e-3
a += 123.4567
imshow(a)
colorbar()
title('> 0 OOM -2, case + 2')
subplot(248)
a = -a
imshow(a)
colorbar()
title('< 0 OOM -2, case + 2')
draw()
show()
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel