File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
subplots_axes_and_figures Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 12
12
r = np .arange (0 , 2 , 0.01 )
13
13
theta = 2 * np .pi * r
14
14
15
- ax = plt .subplot ( 111 , projection = ' polar' )
15
+ fig , ax = plt .subplots ( subplot_kw = { 'projection' : ' polar'} )
16
16
ax .plot (theta , r )
17
17
ax .set_rmax (2 )
18
18
ax .set_rticks ([0.5 , 1 , 1.5 , 2 ]) # Less radial ticks
Original file line number Diff line number Diff line change 8
8
import numpy as np
9
9
import matplotlib .pyplot as plt
10
10
11
+ ###############################################################################
12
+
13
+ x1 = np .linspace (0.0 , 5.0 )
14
+ x2 = np .linspace (0.0 , 2.0 )
15
+
16
+ y1 = np .cos (2 * np .pi * x1 ) * np .exp (- x1 )
17
+ y2 = np .cos (2 * np .pi * x2 )
18
+
19
+ fig , (ax1 , ax2 ) = plt .subplots (2 , 1 )
20
+ fig .suptitle ('A tale of 2 subplots' )
21
+
22
+ ax1 .plot (x1 , y1 , 'o-' )
23
+ ax1 .set_ylabel ('Damped oscillation' )
24
+
25
+ ax2 .plot (x2 , y2 , '.-' )
26
+ ax2 .set_xlabel ('time (s)' )
27
+ ax2 .set_ylabel ('Undamped' )
28
+
29
+ plt .show ()
30
+
31
+ #############################################################################
32
+ #
33
+ #
34
+ # Alternative Method For Creating Multiple Plots
35
+ # """"""""""""""""""""""""""""""""""""""""""""""
36
+ #
37
+ # Subplots can also be generated using `~.pyplot.subplot()` \
38
+ # as in the following example:
39
+ #
40
+
11
41
12
42
x1 = np .linspace (0.0 , 5.0 )
13
43
x2 = np .linspace (0.0 , 2.0 )
You can’t perform that action at this time.
0 commit comments