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

Skip to content

Commit 5702b89

Browse files
committed
FIX: rename to FuncScale
1 parent 2e61178 commit 5702b89

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

examples/scales/custom_scale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
Unless you are making special use of the `~.Transform` class, you probably
1010
don't need to use this verbose method, and instead can use
11-
`~.matplotlib.scale.ArbitraryScale` and the ``'arbitrary'`` option of
11+
`~.matplotlib.scale.FuncScale` and the ``'function'`` option of
1212
`~.matplotlib.axes.Axes.set_xscale` and `~.matplotlib.axes.Axes.set_yscale`.
1313
See the last example in :doc:`/gallery/scales/scales`.
1414
"""

examples/scales/scales.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Illustrate the scale transformations applied to axes, e.g. log, symlog, logit.
77
8-
The last two examples are examples of using the ``'arbitrary'`` scale by
8+
The last two examples are examples of using the ``'function'`` scale by
99
supplying forward and inverse functions for the scale transformation.
1010
"""
1111
import numpy as np
@@ -57,7 +57,7 @@
5757
ax.yaxis.set_minor_formatter(NullFormatter())
5858

5959

60-
# Arbitrary x**(1/2)
60+
# Function x**(1/2)
6161
def forward(x):
6262
return x**(1/2)
6363

@@ -68,14 +68,14 @@ def inverse(x):
6868

6969
ax = axs[2, 0]
7070
ax.plot(x, y)
71-
ax.set_yscale('arbitrary', functions=(forward, inverse))
72-
ax.set_title('arbitrary: $x^{1/2}$')
71+
ax.set_yscale('function', functions=(forward, inverse))
72+
ax.set_title('function: $x^{1/2}$')
7373
ax.grid(True)
7474
ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 1, 0.2)**2))
7575
ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 1, 0.2)))
7676

7777

78-
# Arbitrary Mercator transform
78+
# Function Mercator transform
7979
def forward(a):
8080
a = np.deg2rad(a)
8181
# mask values too close to +/- 90, which are ill-defined.
@@ -99,8 +99,8 @@ def inverse(a):
9999

100100
ax.plot(t, s, '-', lw=2)
101101

102-
ax.set_yscale('arbitrary', functions=(forward, inverse))
103-
ax.set_title('arbitrary: Mercator')
102+
ax.set_yscale('function', functions=(forward, inverse))
103+
ax.set_title('function: Mercator')
104104
ax.grid(True)
105105
ax.set_xlim([-180, 180])
106106
ax.yaxis.set_minor_formatter(NullFormatter())
@@ -126,4 +126,4 @@ def inverse(a):
126126
matplotlib.scale.LogScale
127127
matplotlib.scale.LinearScale
128128
matplotlib.scale.SymmetricalLogScale
129-
matplotlib.scale.ArbitraryScale
129+
matplotlib.scale.FuncScale

lib/matplotlib/scale.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_transform(self):
9494
return IdentityTransform()
9595

9696

97-
class ArbitraryTransform(Transform):
97+
class FuncTransform(Transform):
9898
"""
9999
A simple transform that takes and arbitrary function for the
100100
forward and inverse transform.
@@ -126,22 +126,22 @@ def forward(values: array-like) ->
126126
self._forward = forward
127127
self._inverse = inverse
128128
else:
129-
raise ValueError('arguments to ArbitraryTransform must '
129+
raise ValueError('arguments to FuncTransform must '
130130
'be functions')
131131

132132
def transform_non_affine(self, values):
133133
return self._forward(values)
134134

135135
def inverted(self):
136-
return ArbitraryTransform(self._inverse, self._forward)
136+
return FuncTransform(self._inverse, self._forward)
137137

138138

139-
class ArbitraryScale(ScaleBase):
139+
class FuncScale(ScaleBase):
140140
"""
141-
Provide an arbitrary scale for the axis.
141+
Provide an arbitrary scale with user-supplied function for the axis.
142142
"""
143143

144-
name = 'arbitrary'
144+
name = 'function'
145145

146146
def __init__(self, axis, functions):
147147
"""
@@ -161,7 +161,7 @@ def forward(values: array-like) ->
161161
array-likeThe forward function for the transform
162162
"""
163163
forward, inverse = functions
164-
transform = ArbitraryTransform(forward, inverse)
164+
transform = FuncTransform(forward, inverse)
165165
self._transform = transform
166166

167167
def get_transform(self):
@@ -179,7 +179,8 @@ def set_default_locators_and_formatters(self, axis):
179179
axis.set_major_formatter(ScalarFormatter())
180180
axis.set_minor_formatter(NullFormatter())
181181
# update the minor locator for x and y axis based on rcParams
182-
if rcParams['xtick.minor.visible']:
182+
if (axis.axis_name == 'x' and rcParams['xtick.minor.visible']
183+
or axis.axis_name == 'y' and rcParams['ytick.minor.visible']):
183184
axis.set_minor_locator(AutoMinorLocator())
184185
else:
185186
axis.set_minor_locator(NullLocator())
@@ -648,7 +649,7 @@ def limit_range_for_scale(self, vmin, vmax, minpos):
648649
'log': LogScale,
649650
'symlog': SymmetricalLogScale,
650651
'logit': LogitScale,
651-
'arbitrary': ArbitraryScale,
652+
'function': FuncScale,
652653
}
653654

654655

lib/matplotlib/tests/test_scale.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def test_invalid_log_lims():
152152
assert ax.get_ylim() == original_ylim
153153

154154

155-
@image_comparison(baseline_images=['arbitrary_scales'], remove_text=True,
155+
@image_comparison(baseline_images=['function_scales'], remove_text=True,
156156
extensions=['png'], style='mpl20')
157-
def test_arbitrary_scale():
157+
def test_function_scale():
158158
def inverse(x):
159159
return x**2
160160

@@ -169,5 +169,5 @@ def forward(x):
169169
x = np.arange(1, 1000)
170170

171171
ax.plot(x, x)
172-
ax.set_xscale('arbitrary', functions=(forward, inverse))
172+
ax.set_xscale('function', functions=(forward, inverse))
173173
ax.set_xlim(1, 1000)

0 commit comments

Comments
 (0)