File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change 6
6
import matplotlib as mpl
7
7
import matplotlib .pyplot as plt
8
8
9
- styles = ['default' ] + plt .style .available
10
-
11
- for style in styles :
12
- fig = plt .figure (figsize = (5 ,3 ), dpi = 100 )
13
- plt .style .use (style )
14
- ax = plt .subplot (1 ,1 ,1 )
15
- X = np .linspace (0 ,2 * np .pi , 256 )
16
- Y = np .cos (X )
17
- ax .plot (X ,Y )
18
- plt .title (style , family = "Source Serif Pro" , size = 32 )
19
- plt .tight_layout ()
20
- # plt.show()
21
- plt .savefig ("../figures/style-%s.pdf" % style )
22
- plt .close (fig )
9
+ for style in ['default' ] + plt .style .available :
10
+ with plt .style .context (style ):
11
+ fig = plt .figure (figsize = (5 ,3 ), dpi = 100 )
12
+ ax = plt .subplot (1 ,1 ,1 )
13
+ X = np .linspace (0 ,2 * np .pi , 256 )
14
+ Y = np .cos (X )
15
+ ax .plot (X ,Y )
16
+ plt .title (style , family = "Source Serif Pro" , size = 32 )
17
+ plt .tight_layout ()
18
+ plt .savefig ("../figures/style-%s.pdf" % style )
19
+ plt .close (fig )
23
20
24
21
You can’t perform that action at this time.
0 commit comments