Skip to content

Commit 8af1a17

Browse files
authored
Merge pull request matplotlib#20626 from anntzer/utr
Simplify curvilinear grid examples.
2 parents d11b206 + 20ac9ef commit 8af1a17

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

examples/axisartist/demo_curvelinear_grid.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,17 @@ def curvelinear_test1(fig):
2727
Grid for custom transform.
2828
"""
2929

30-
def tr(x, y):
31-
x, y = np.asarray(x), np.asarray(y)
32-
return x, y - x
33-
34-
def inv_tr(x, y):
35-
x, y = np.asarray(x), np.asarray(y)
36-
return x, y + x
30+
def tr(x, y): return x, y - x
31+
def inv_tr(x, y): return x, y + x
3732

3833
grid_helper = GridHelperCurveLinear((tr, inv_tr))
3934

4035
ax1 = fig.add_subplot(1, 2, 1, axes_class=Axes, grid_helper=grid_helper)
41-
# ax1 will have a ticks and gridlines defined by the given
42-
# transform (+ transData of the Axes). Note that the transform of
43-
# the Axes itself (i.e., transData) is not affected by the given
44-
# transform.
45-
46-
xx, yy = tr([3, 6], [5, 10])
47-
ax1.plot(xx, yy, linewidth=2.0)
36+
# ax1 will have ticks and gridlines defined by the given transform (+
37+
# transData of the Axes). Note that the transform of the Axes itself
38+
# (i.e., transData) is not affected by the given transform.
39+
xx, yy = tr(np.array([3, 6]), np.array([5, 10]))
40+
ax1.plot(xx, yy)
4841

4942
ax1.set_aspect(1)
5043
ax1.set_xlim(0, 10)

examples/axisartist/demo_curvelinear_grid2.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ def curvelinear_test1(fig):
2424
"""Grid for custom transform."""
2525

2626
def tr(x, y):
27-
sgn = np.sign(x)
28-
x, y = np.abs(np.asarray(x)), np.asarray(y)
29-
return sgn*x**.5, y
27+
return np.sign(x)*abs(x)**.5, y
3028

3129
def inv_tr(x, y):
32-
sgn = np.sign(x)
33-
x, y = np.asarray(x), np.asarray(y)
34-
return sgn*x**2, y
30+
return np.sign(x)*x**2, y
3531

3632
grid_helper = GridHelperCurveLinear(
3733
(tr, inv_tr),

0 commit comments

Comments
 (0)