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

Skip to content

Commit a3ec8b0

Browse files
committed
Merge pull request matplotlib#1314 from bblay/pcmrange
Range bug fix for pcolor and pcolormesh
2 parents b6cf115 + 93acf56 commit a3ec8b0

File tree

4 files changed

+2809
-2758
lines changed

4 files changed

+2809
-2758
lines changed

lib/matplotlib/axes.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7364,6 +7364,20 @@ def pcolor(self, *args, **kwargs):
73647364

73657365
x = X.compressed()
73667366
y = Y.compressed()
7367+
7368+
# Transform from native to data coordinates?
7369+
t = collection._transform
7370+
if (not isinstance(t, mtransforms.Transform)
7371+
and hasattr(t, '_as_mpl_transform')):
7372+
t = t._as_mpl_transform(self.axes)
7373+
7374+
if t and any(t.contains_branch_seperately(self.transData)):
7375+
trans_to_data = t - self.transData
7376+
pts = np.vstack([x, y]).T.astype(np.float)
7377+
transformed_pts = trans_to_data.transform(pts)
7378+
x = transformed_pts[..., 0]
7379+
y = transformed_pts[..., 1]
7380+
73677381
minx = np.amin(x)
73687382
maxx = np.amax(x)
73697383
miny = np.amin(y)
@@ -7490,6 +7504,19 @@ def pcolormesh(self, *args, **kwargs):
74907504
collection.autoscale_None()
74917505

74927506
self.grid(False)
7507+
7508+
# Transform from native to data coordinates?
7509+
t = collection._transform
7510+
if (not isinstance(t, mtransforms.Transform)
7511+
and hasattr(t, '_as_mpl_transform')):
7512+
t = t._as_mpl_transform(self.axes)
7513+
7514+
if t and any(t.contains_branch_seperately(self.transData)):
7515+
trans_to_data = t - self.transData
7516+
pts = np.vstack([X, Y]).T.astype(np.float)
7517+
transformed_pts = trans_to_data.transform(pts)
7518+
X = transformed_pts[..., 0]
7519+
Y = transformed_pts[..., 1]
74937520

74947521
minx = np.amin(X)
74957522
maxx = np.amax(X)

0 commit comments

Comments
 (0)