2727colors = [cmap (i ) for i in [0.1 , 0.3 , 0.5 , 0.7 ]]
2828ax .hist (X , 2 , density = True , histtype = 'bar' , color = colors )
2929
30- plt .savefig ("../figures/tip-color-range.pdf" )
30+ fig .savefig ("../figures/tip-color-range.pdf" )
3131
3232
3333# colorbar
4242cb = fig .colorbar (im , fraction = 0.046 , pad = 0.04 )
4343cb .set_ticks ([])
4444
45- plt .savefig ("../figures/tip-colorbar.pdf" )
45+ fig .savefig ("../figures/tip-colorbar.pdf" )
4646
4747
4848# dotted
5454)
5555
5656epsilon = 1e-12
57- plt .plot ([0 ,1 ], [0 ,0 ], "black" , clip_on = False , lw = 8 ,
57+ ax .plot ([0 ,1 ], [0 ,0 ], "black" , clip_on = False , lw = 8 ,
5858 ls = (.5 ,(epsilon , 1 )), dash_capstyle = "round" )
59- plt .plot ([0 ,1 ], [1 ,1 ], "black" , clip_on = False , lw = 8 ,
59+ ax .plot ([0 ,1 ], [1 ,1 ], "black" , clip_on = False , lw = 8 ,
6060 ls = (- .5 ,(epsilon , 2 )), dash_capstyle = "round" )
61- plt .savefig ("../figures/tip-dotted.pdf" )
61+ fig .savefig ("../figures/tip-dotted.pdf" )
6262
6363
6464# dual axis
7979ax2 .set_xticklabels ([])
8080ax2 .set_yticklabels ([])
8181
82- plt .savefig ("../figures/tip-dual-axis.pdf" )
82+ fig .savefig ("../figures/tip-dual-axis.pdf" )
8383
8484
8585# font family
@@ -121,17 +121,17 @@ def setup(ax):
121121for tick in ax .get_xticklabels (which = 'both' ):
122122 tick .set_fontname ("Roboto Condensed" )
123123
124- plt .tight_layout ()
125- plt .savefig ("../figures/tip-font-family.pdf" , transparent = True )
124+ fig .tight_layout ()
125+ fig .savefig ("../figures/tip-font-family.pdf" , transparent = True )
126126
127127
128128# hatched
129129# -----------------------------------------------------------------------------
130130cmap = plt .get_cmap ("Oranges" )
131131color1 , color2 = cmap (0.3 ), cmap (0.5 )
132132
133- plt .rcParams ['hatch.color' ] = color1
134- plt .rcParams ['hatch.linewidth' ] = 8
133+ mpl .rcParams ['hatch.color' ] = color1
134+ mpl .rcParams ['hatch.linewidth' ] = 8
135135
136136fig = plt .figure (figsize = (2 , 2 ))
137137ax = plt .subplot ()
@@ -142,13 +142,13 @@ def setup(ax):
142142
143143ax .bar (x1 , y1 , color = color2 )
144144for i in range (len (x1 )):
145- plt .annotate ("%d%%" % y1 [i ], (x1 [i ], y1 [i ]), xytext = (0 ,1 ),
145+ ax .annotate ("%d%%" % y1 [i ], (x1 [i ], y1 [i ]), xytext = (0 ,1 ),
146146 fontsize = "x-small" , color = color2 ,
147147 textcoords = "offset points" , va = "bottom" , ha = "center" )
148148
149149ax .bar (x2 , y2 , color = color2 , hatch = "/" )
150150for i in range (len (x2 )):
151- plt .annotate ("%d%%" % y2 [i ], (x2 [i ], y2 [i ]), xytext = (0 ,1 ),
151+ ax .annotate ("%d%%" % y2 [i ], (x2 [i ], y2 [i ]), xytext = (0 ,1 ),
152152 fontsize = "x-small" , color = color2 ,
153153 textcoords = "offset points" , va = "bottom" , ha = "center" )
154154
@@ -161,8 +161,8 @@ def setup(ax):
161161ax .spines ['left' ].set_visible (False )
162162ax .spines ['top' ].set_visible (False )
163163
164- plt .tight_layout ()
165- plt .savefig ("../figures/tip-hatched.pdf" )
164+ fig .tight_layout ()
165+ fig .savefig ("../figures/tip-hatched.pdf" )
166166
167167
168168# multiline
@@ -175,12 +175,12 @@ def setup(ax):
175175 X .extend ([x , x , None ])
176176 Y .extend ([0 , np .sin (x ), None ])
177177print (X [:10 ], Y [:10 ])
178- plt .plot (X , Y , "black" )
179- plt . xticks ([]), plt . yticks ([])
180- plt . xlim (- 0.25 , 10 * np .pi + 0.25 )
181- plt . ylim (- 1.5 , 1.5 )
182- plt .tight_layout ()
183- plt .savefig ("../figures/tip-multiline.pdf" , dpi = 100 )
178+ ax .plot (X , Y , "black" )
179+ ax . set_xticks ([]), ax . set_yticks ([])
180+ ax . set_xlim (- 0.25 , 10 * np .pi + 0.25 )
181+ ax . set_ylim (- 1.5 , 1.5 )
182+ fig .tight_layout ()
183+ fig .savefig ("../figures/tip-multiline.pdf" , dpi = 100 )
184184
185185
186186# outline
@@ -197,7 +197,7 @@ def setup(ax):
197197 color = cmap (0.9 ), size = 32 , weight = "bold" , ha = "center" , va = "bottom" )
198198text .set_path_effects ([path_effects .Stroke (linewidth = 5 , foreground = 'white' ),
199199 path_effects .Normal ()])
200- plt .savefig ("../figures/tip-outline.pdf" )
200+ fig .savefig ("../figures/tip-outline.pdf" )
201201
202202
203203# transparency
@@ -214,4 +214,4 @@ def setup(ax):
214214
215215ax .set_xlim ([- 1 , 1 ]), ax .set_xticks ([]),
216216ax .set_ylim ([- 1 , 1 ]), ax .set_yticks ([])
217- plt .savefig ("../figures/tip-transparency.pdf" )
217+ fig .savefig ("../figures/tip-transparency.pdf" )
0 commit comments