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

Skip to content

Commit 1cc9ed6

Browse files
author
James Evans
committed
Fixed contour to now properly strip away units for unitized data on the x and y axes.
Unit registry now properly determines the registered converter to use for nested array data types. svn path=/trunk/matplotlib/; revision=6097
1 parent a760440 commit 1cc9ed6

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/matplotlib/contour.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,12 @@ def _check_xyz(self, args):
724724
Possible change: I think we should make and use an ArgumentError
725725
Exception class (here and elsewhere).
726726
'''
727-
x = np.asarray(args[0], dtype=np.float64)
728-
y = np.asarray(args[1], dtype=np.float64)
727+
# We can strip away the x and y units
728+
x = self.ax.convert_xunits( args[0] )
729+
y = self.ax.convert_yunits( args[1] )
730+
731+
x = np.asarray(x, dtype=np.float64)
732+
y = np.asarray(y, dtype=np.float64)
729733
z = ma.asarray(args[2], dtype=np.float64)
730734
if z.ndim != 2:
731735
raise TypeError("Input z must be a 2D array.")

lib/matplotlib/units.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,8 @@ def get_converter(self, x):
128128

129129
if converter is None and iterable(x):
130130
for thisx in x:
131-
classx = getattr(thisx, '__class__', None)
132-
break
133-
if classx is not None:
134-
converter = self.get(classx)
135-
131+
converter = self.get_converter( thisx )
132+
if converter: break
136133

137134
#DISABLED self._cached[idx] = converter
138135
return converter

0 commit comments

Comments
 (0)