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

Skip to content

Commit 0c7f227

Browse files
committed
DOC: Improve inverted axis example
Closes #28050.
1 parent d45dfbb commit 0c7f227

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed
Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
"""
2-
===========
3-
Invert Axes
4-
===========
2+
=============
3+
Inverted axis
4+
=============
55
6-
You can use decreasing axes by flipping the normal order of the axis
7-
limits
6+
To invert an axis, you can explicitly set inverted axis limits or you
7+
can invert the axis without specifying any limits using
8+
`.Axis.set_inverted`.
89
"""
910

1011
import matplotlib.pyplot as plt
1112
import numpy as np
1213

13-
t = np.arange(0.01, 5.0, 0.01)
14+
t = np.arange(0.01, 4.0, 0.01)
1415
s = np.exp(-t)
1516

16-
fig, ax = plt.subplots()
17+
fig, (ax1, ax2) = plt.subplots(1, 2)
18+
fig.suptitle('Should be growing...')
19+
20+
ax1.plot(t, s)
21+
ax1.set_xlim(4, 0) # decreasing time
22+
ax1.set_title('Inverted fixed limits')
23+
ax1.set_xlabel('decreasing time (s)')
24+
ax1.grid(True)
25+
26+
ax2.plot(t, s)
27+
ax2.xaxis.set_inverted(True) # decreasing time
28+
ax2.set_title('Inverted axis with autoscaling')
29+
ax2.set_xlabel('decreasing time (s)')
30+
ax2.grid(True)
1731

18-
ax.plot(t, s)
19-
ax.set_xlim(5, 0) # decreasing time
20-
ax.set_xlabel('decreasing time (s)')
21-
ax.set_ylabel('voltage (mV)')
22-
ax.set_title('Should be growing...')
23-
ax.grid(True)
2432

2533
plt.show()

0 commit comments

Comments
 (0)