File tree 1 file changed +21
-13
lines changed
galleries/examples/subplots_axes_and_figures 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- ===========
3
- Invert Axes
4
- ===========
2
+ =============
3
+ Inverted axis
4
+ =============
5
5
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`.
8
9
"""
9
10
10
11
import matplotlib .pyplot as plt
11
12
import numpy as np
12
13
13
- t = np .arange (0.01 , 5 .0 , 0.01 )
14
+ t = np .arange (0.01 , 4 .0 , 0.01 )
14
15
s = np .exp (- t )
15
16
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 )
17
31
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 )
24
32
25
33
plt .show ()
You can’t perform that action at this time.
0 commit comments