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

Commitc670b3e

Browse files
committed
FIX: more fixes
1 parentc532b71 commitc670b3e

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 wanttolabelthetop 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 tupleto the``functions`` kwarg:
1212
"""
1313

1414
importmatplotlib.pyplotasplt
@@ -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
defdeg2rad(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
@@ -835,7 +835,7 @@ def set_yscale(self, value, **kwargs):
835835

836836
defset_zscale(self,value,**kwargs):
837837
"""
838-
Set thex-axis scale.
838+
Set thez-axis scale.
839839
840840
Parameters
841841
----------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp