Skip to content

Commit daa7b1d

Browse files
committed
Fix NonUniformImage with nonlinear scale
1 parent 975b584 commit daa7b1d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/image.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,16 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
10851085
B[:, :, 0:3] = A
10861086
B[:, :, 3] = 255
10871087
A = B
1088-
vl = self.axes.viewLim
10891088
l, b, r, t = self.axes.bbox.extents
10901089
width = int(((round(r) + 0.5) - (round(l) - 0.5)) * magnification)
10911090
height = int(((round(t) + 0.5) - (round(b) - 0.5)) * magnification)
1092-
x_pix = np.linspace(vl.x0, vl.x1, width)
1093-
y_pix = np.linspace(vl.y0, vl.y1, height)
1091+
1092+
invertedTransform = self.axes.transData.inverted()
1093+
x_pix = invertedTransform.transform(
1094+
[(x, b) for x in np.linspace(l, r, width)])[:, 0]
1095+
y_pix = invertedTransform.transform(
1096+
[(l, y) for y in np.linspace(b, t, height)])[:, 1]
1097+
10941098
if self._interpolation == "nearest":
10951099
x_mid = (self._Ax[:-1] + self._Ax[1:]) / 2
10961100
y_mid = (self._Ay[:-1] + self._Ay[1:]) / 2

0 commit comments

Comments
 (0)