Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3101e00

Browse filesBrowse files
committed
LogNorm.autoscale ignores nonpositive values; closes 2953069
svn path=/trunk/matplotlib/; revision=8348
1 parent 9226ef5 commit 3101e00
Copy full SHA for 3101e00

File tree

1 file changed

+20
-0
lines changed
Filter options

1 file changed

+20
-0
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,8 @@ def __call__(self, value, clip=None):
850850
vtype = 'scalar'
851851
val = ma.array([value]).astype(np.float)
852852

853+
val = ma.masked_less_equal(val, 0, copy=False)
854+
853855
self.autoscale_None(val)
854856
vmin, vmax = self.vmin, self.vmax
855857
if vmin > vmax:
@@ -879,6 +881,24 @@ def inverse(self, value):
879881
else:
880882
return vmin * pow((vmax/vmin), value)
881883

884+
def autoscale(self, A):
885+
'''
886+
Set *vmin*, *vmax* to min, max of *A*.
887+
'''
888+
A = ma.masked_less_equal(A, 0, copy=False)
889+
self.vmin = ma.min(A)
890+
self.vmax = ma.max(A)
891+
892+
def autoscale_None(self, A):
893+
' autoscale only None-valued vmin or vmax'
894+
if self.vmin is not None and self.vmax is not None:
895+
return
896+
A = ma.masked_less_equal(A, 0, copy=False)
897+
if self.vmin is None:
898+
self.vmin = ma.min(A)
899+
if self.vmax is None:
900+
self.vmax = ma.max(A)
901+
882902
class BoundaryNorm(Normalize):
883903
'''
884904
Generate a colormap index based on discrete intervals.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.