File tree Expand file tree Collapse file tree
subplots_axes_and_figures Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212r = np .arange (0 , 2 , 0.01 )
1313theta = 2 * np .pi * r
1414
15- ax = plt .subplot ( 111 , projection = ' polar' )
15+ fig , ax = plt .subplots ( subplot_kw = { 'projection' : ' polar'} )
1616ax .plot (theta , r )
1717ax .set_rmax (2 )
1818ax .set_rticks ([0.5 , 1 , 1.5 , 2 ]) # Less radial ticks
Original file line number Diff line number Diff line change 88import numpy as np
99import matplotlib .pyplot as plt
1010
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+
1141
1242x1 = np .linspace (0.0 , 5.0 )
1343x2 = np .linspace (0.0 , 2.0 )
You can’t perform that action at this time.
0 commit comments