27
27
colors = [cmap (i ) for i in [0.1 , 0.3 , 0.5 , 0.7 ]]
28
28
ax .hist (X , 2 , density = True , histtype = 'bar' , color = colors )
29
29
30
- plt .savefig ("../figures/tip-color-range.pdf" )
30
+ fig .savefig ("../figures/tip-color-range.pdf" )
31
31
32
32
33
33
# colorbar
42
42
cb = fig .colorbar (im , fraction = 0.046 , pad = 0.04 )
43
43
cb .set_ticks ([])
44
44
45
- plt .savefig ("../figures/tip-colorbar.pdf" )
45
+ fig .savefig ("../figures/tip-colorbar.pdf" )
46
46
47
47
48
48
# dotted
54
54
)
55
55
56
56
epsilon = 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 ,
58
58
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 ,
60
60
ls = (- .5 ,(epsilon , 2 )), dash_capstyle = "round" )
61
- plt .savefig ("../figures/tip-dotted.pdf" )
61
+ fig .savefig ("../figures/tip-dotted.pdf" )
62
62
63
63
64
64
# dual axis
79
79
ax2 .set_xticklabels ([])
80
80
ax2 .set_yticklabels ([])
81
81
82
- plt .savefig ("../figures/tip-dual-axis.pdf" )
82
+ fig .savefig ("../figures/tip-dual-axis.pdf" )
83
83
84
84
85
85
# font family
@@ -121,17 +121,17 @@ def setup(ax):
121
121
for tick in ax .get_xticklabels (which = 'both' ):
122
122
tick .set_fontname ("Roboto Condensed" )
123
123
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 )
126
126
127
127
128
128
# hatched
129
129
# -----------------------------------------------------------------------------
130
130
cmap = plt .get_cmap ("Oranges" )
131
131
color1 , color2 = cmap (0.3 ), cmap (0.5 )
132
132
133
- plt .rcParams ['hatch.color' ] = color1
134
- plt .rcParams ['hatch.linewidth' ] = 8
133
+ mpl .rcParams ['hatch.color' ] = color1
134
+ mpl .rcParams ['hatch.linewidth' ] = 8
135
135
136
136
fig = plt .figure (figsize = (2 , 2 ))
137
137
ax = plt .subplot ()
@@ -142,13 +142,13 @@ def setup(ax):
142
142
143
143
ax .bar (x1 , y1 , color = color2 )
144
144
for 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 ),
146
146
fontsize = "x-small" , color = color2 ,
147
147
textcoords = "offset points" , va = "bottom" , ha = "center" )
148
148
149
149
ax .bar (x2 , y2 , color = color2 , hatch = "/" )
150
150
for 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 ),
152
152
fontsize = "x-small" , color = color2 ,
153
153
textcoords = "offset points" , va = "bottom" , ha = "center" )
154
154
@@ -161,8 +161,8 @@ def setup(ax):
161
161
ax .spines ['left' ].set_visible (False )
162
162
ax .spines ['top' ].set_visible (False )
163
163
164
- plt .tight_layout ()
165
- plt .savefig ("../figures/tip-hatched.pdf" )
164
+ fig .tight_layout ()
165
+ fig .savefig ("../figures/tip-hatched.pdf" )
166
166
167
167
168
168
# multiline
@@ -175,12 +175,12 @@ def setup(ax):
175
175
X .extend ([x , x , None ])
176
176
Y .extend ([0 , np .sin (x ), None ])
177
177
print (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 )
184
184
185
185
186
186
# outline
@@ -197,7 +197,7 @@ def setup(ax):
197
197
color = cmap (0.9 ), size = 32 , weight = "bold" , ha = "center" , va = "bottom" )
198
198
text .set_path_effects ([path_effects .Stroke (linewidth = 5 , foreground = 'white' ),
199
199
path_effects .Normal ()])
200
- plt .savefig ("../figures/tip-outline.pdf" )
200
+ fig .savefig ("../figures/tip-outline.pdf" )
201
201
202
202
203
203
# transparency
@@ -214,4 +214,4 @@ def setup(ax):
214
214
215
215
ax .set_xlim ([- 1 , 1 ]), ax .set_xticks ([]),
216
216
ax .set_ylim ([- 1 , 1 ]), ax .set_yticks ([])
217
- plt .savefig ("../figures/tip-transparency.pdf" )
217
+ fig .savefig ("../figures/tip-transparency.pdf" )
0 commit comments