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

Skip to content

Commit 67ef64e

Browse files
committed
FIX: more fixes
1 parent 1e7f060 commit 67ef64e

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

examples/subplots_axes_and_figures/secondary_axis.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
Sometimes we want as secondary axis on a plot, for instance to convert
77
radians to degrees on the same plot. We can do this by making a child
88
axes with only one axis visible via `.Axes.axes.secondary_xaxis` and
9-
`.Axes.axes.secondary_yaxis`.
10-
11-
If we want to label the top of the axes:
9+
`.Axes.axes.secondary_yaxis`. This secondary axis can have a different scale
10+
than the main axis by providing both a forward and an inverse conversion
11+
function in a tuple to the ``functions`` kwarg:
1212
"""
1313

1414
import matplotlib.pyplot as plt
@@ -26,22 +26,6 @@
2626
ax.set_xlabel('angle [degrees]')
2727
ax.set_ylabel('signal')
2828
ax.set_title('Sine wave')
29-
secax = ax.secondary_xaxis('top')
30-
plt.show()
31-
32-
###########################################################################
33-
# However, its often useful to label the secondary axis with something
34-
# other than the labels in the main axis. In that case we need to provide
35-
# both a forward and an inverse conversion function in a tuple
36-
# to the ``functions`` kwarg:
37-
38-
fig, ax = plt.subplots(constrained_layout=True)
39-
x = np.arange(0, 360, 1)
40-
y = np.sin(2 * x * np.pi / 180)
41-
ax.plot(x, y)
42-
ax.set_xlabel('angle [degrees]')
43-
ax.set_ylabel('signal')
44-
ax.set_title('Sine wave')
4529

4630

4731
def deg2rad(x):
@@ -98,6 +82,7 @@ def inverse(x):
9882

9983
xold = np.arange(0, 11, 0.2)
10084
# fake data set relating x co-ordinate to another data-derived co-ordinate.
85+
# xnew must be monotonic, so we sort...
10186
xnew = np.sort(10 * np.exp(-xold / 4) + np.random.randn(len(xold)) / 3)
10287

10388
ax.plot(xold[3:], xnew[3:], label='Transform data')

lib/matplotlib/scale.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def __init__(self, axis, functions):
163163
164164
functions : (callable, callable)
165165
two-tuple of the forward and inverse functions for the scale.
166-
The forward function must have an inverse and, for best behavior,
167-
be monotonic.
166+
The forward function must be monotonic
168167
169168
Both functions must have the signature::
170169
@@ -426,8 +425,7 @@ def __init__(self, axis, functions, base=10):
426425
427426
functions : (callable, callable)
428427
two-tuple of the forward and inverse functions for the scale.
429-
The forward function must have an inverse and, for best behavior,
430-
be monotonic.
428+
The forward function must be monotonic.
431429
432430
Both functions must have the signature::
433431

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def set_yscale(self, value, **kwargs):
829829

830830
def set_zscale(self, value, **kwargs):
831831
"""
832-
Set the x-axis scale.
832+
Set the z-axis scale.
833833
834834
Parameters
835835
----------

0 commit comments

Comments
 (0)