Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

BUG: Fix NonUniformImage with nonlinear scale#27964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ksunden merged 2 commits intomatplotlib:mainfromtrananso:fix-logscale-axis
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1085,12 +1085,16 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
B[:, :, 0:3] = A
B[:, :, 3] = 255
A = B
vl = self.axes.viewLim
l, b, r, t = self.axes.bbox.extents
width = int(((round(r) + 0.5) - (round(l) - 0.5)) * magnification)
height = int(((round(t) + 0.5) - (round(b) - 0.5)) * magnification)
x_pix = np.linspace(vl.x0, vl.x1, width)
y_pix = np.linspace(vl.y0, vl.y1, height)

invertedTransform = self.axes.transData.inverted()
x_pix = invertedTransform.transform(
[(x, b) for x in np.linspace(l, r, width)])[:, 0]
y_pix = invertedTransform.transform(
[(l, y) for y in np.linspace(b, t, height)])[:, 1]

if self._interpolation == "nearest":
x_mid = (self._Ax[:-1] + self._Ax[1:]) / 2
y_mid = (self._Ay[:-1] + self._Ay[1:]) / 2
Expand Down
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletionslib/matplotlib/tests/test_image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1406,6 +1406,27 @@ def test_nonuniform_and_pcolor():
ax.set(xlim=(0, 10))


@image_comparison(["nonuniform_logscale.png"], style="mpl20")
def test_nonuniform_logscale():
_, axs = plt.subplots(ncols=3, nrows=1)

for i in range(3):
ax = axs[i]
im = NonUniformImage(ax)
im.set_data(np.arange(1, 4) ** 2, np.arange(1, 4) ** 2,
np.arange(9).reshape((3, 3)))
ax.set_xlim(1, 16)
ax.set_ylim(1, 16)
ax.set_box_aspect(1)
if i == 1:
ax.set_xscale("log", base=2)
ax.set_yscale("log", base=2)
if i == 2:
ax.set_xscale("log", base=4)
ax.set_yscale("log", base=4)
ax.add_image(im)


@image_comparison(
['rgba_antialias.png'], style='mpl20', remove_text=True,
tol=0 if platform.machine() == 'x86_64' else 0.007)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp