1818
1919# color range
2020# -----------------------------------------------------------------------------
21- fig = plt .figure (figsize = (2 ,2 ))
21+ fig = plt .figure (figsize = (2 , 2 ))
2222ax = fig .add_axes (rect , xticks = [], yticks = [])
2323
24- X = np .random .seed (1 )
24+ np .random .seed (1 )
2525X = np .random .randn (1000 , 4 )
2626cmap = plt .get_cmap ("Oranges" )
27- colors = [cmap (i ) for i in [.1 ,.3 ,.5 ,.7 ]]
27+ colors = [cmap (i ) for i in [0 .1 , 0 .3 , 0 .5 , 0 .7 ]]
2828ax .hist (X , 2 , density = True , histtype = 'bar' , color = colors )
2929
3030plt .savefig ("../figures/tip-color-range.pdf" )
3131
3232
3333# colorbar
3434# -----------------------------------------------------------------------------
35- fig = plt .figure (figsize = (2.15 ,2 ))
35+ fig = plt .figure (figsize = (2.15 , 2 ))
3636ax = fig .add_axes (rect , xticks = [], yticks = [])
3737
3838np .random .seed (1 )
39- Z = np .random .uniform (0 ,1 , (8 ,8 ))
39+ Z = np .random .uniform (0 , 1 , (8 , 8 ))
4040cmap = plt .get_cmap ("Oranges" )
4141im = ax .imshow (Z , interpolation = "nearest" , cmap = cmap , vmin = 0 , vmax = 2 )
4242cb = fig .colorbar (im , fraction = 0.046 , pad = 0.04 )
4747
4848# dotted
4949# -----------------------------------------------------------------------------
50- fig = plt .figure (figsize = (5 ,.25 ))
50+ fig = plt .figure (figsize = (5 , 0 .25 ))
5151
52- ax = fig .add_axes ([0 ,0 ,1 ,1 ], frameon = False ,
53- xticks = [], yticks = [], xlim = [0 ,1 ], ylim = [- .5 ,1.5 ])
52+ ax = fig .add_axes (
53+ [0 , 0 , 1 , 1 ], frameon = False , xticks = [], yticks = [], xlim = [0 , 1 ], ylim = [- 0.5 , 1.5 ]
54+ )
5455
5556epsilon = 1e-12
5657plt .plot ([0 ,1 ], [0 ,0 ], "black" , clip_on = False , lw = 8 ,
6263
6364# dual axis
6465# -----------------------------------------------------------------------------
65- fig = plt .figure (figsize = (2 ,2 ))
66+ fig = plt .figure (figsize = (2 , 2 ))
6667ax1 = fig .add_axes (rect , label = "cartesian" )
6768ax2 = fig .add_axes (rect , projection = "polar" , label = "polar" )
6869
69- ax1 .set_xticks ([]) # np.linspace(0.0, 0.4, 5))
70- ax1 .set_yticks ([]) # np.linspace(0.0, 1.0, 11))
70+ ax1 .set_xticks ([]) # np.linspace(0.0, 0.4, 5))
71+ ax1 .set_yticks ([]) # np.linspace(0.0, 1.0, 11))
7172
7273ax2 .set_rorigin (0 )
7374ax2 .set_thetamax (90 )
74- ax2 .set_ylim (0.5 ,1.0 )
75+ ax2 .set_ylim (0.5 , 1.0 )
7576ax2 .set_xticks (np .linspace (0 , np .pi / 2 , 10 ))
7677ax2 .set_yticks (np .linspace (0.5 , 1.0 , 5 ))
7778
@@ -103,7 +104,7 @@ def setup(ax):
103104 ax .patch .set_alpha (0.0 )
104105
105106
106- fig = plt .figure (figsize = (5 , .5 ))
107+ fig = plt .figure (figsize = (5 , 0 .5 ))
107108fig .patch .set_alpha (0.0 )
108109n = 1
109110
@@ -132,27 +133,27 @@ def setup(ax):
132133plt .rcParams ['hatch.color' ] = color1
133134plt .rcParams ['hatch.linewidth' ] = 8
134135
135- fig = plt .figure (figsize = (2 ,2 ))
136+ fig = plt .figure (figsize = (2 , 2 ))
136137ax = plt .subplot ()
137138np .random .seed (123 )
138139
139- x1 ,y1 = 3 * np .arange (2 ), np .random .randint (25 ,50 ,2 )
140- x2 ,y2 = x1 + 1 , np .random .randint (25 ,75 ,2 )
140+ x1 , y1 = 3 * np .arange (2 ), np .random .randint (25 , 50 , 2 )
141+ x2 , y2 = x1 + 1 , np .random .randint (25 , 75 , 2 )
141142
142143ax .bar (x1 , y1 , color = color2 )
143144for i in range (len (x1 )):
144145 plt .annotate ("%d%%" % y1 [i ], (x1 [i ], y1 [i ]), xytext = (0 ,1 ),
145146 fontsize = "x-small" , color = color2 ,
146147 textcoords = "offset points" , va = "bottom" , ha = "center" )
147148
148- ax .bar (x2 , y2 , color = color2 , hatch = "/" )
149+ ax .bar (x2 , y2 , color = color2 , hatch = "/" )
149150for i in range (len (x2 )):
150151 plt .annotate ("%d%%" % y2 [i ], (x2 [i ], y2 [i ]), xytext = (0 ,1 ),
151152 fontsize = "x-small" , color = color2 ,
152153 textcoords = "offset points" , va = "bottom" , ha = "center" )
153154
154155ax .set_yticks ([])
155- ax .set_xticks (0.5 + np .arange (0 ,6 , 3 ))
156+ ax .set_xticks (0.5 + np .arange (0 , 6 , 3 ))
156157ax .set_xticklabels (["2018" , "2019" ])
157158ax .tick_params ('x' , length = 0 , labelsize = "small" , which = 'major' )
158159
@@ -166,30 +167,29 @@ def setup(ax):
166167
167168# multiline
168169# -----------------------------------------------------------------------------
169- fig = plt .figure (figsize = (8 ,1.5 ))
170- dx ,dy = 0.0025 , 0.01
170+ fig = plt .figure (figsize = (8 , 1.5 ))
171+ dx , dy = 0.0025 , 0.01
171172ax = fig .add_axes ([dx , dy , 1 - 2 * dx , 1 - 2 * dy ], frameon = False )
172- X ,Y = [], []
173+ X , Y = [], []
173174for x in np .linspace (0.01 , 10 * np .pi - 0.01 , 100 ):
174- X .extend ([x , x ,None ])
175+ X .extend ([x , x , None ])
175176 Y .extend ([0 , np .sin (x ), None ])
176177print (X [:10 ], Y [:10 ])
177178plt .plot (X , Y , "black" )
178179plt .xticks ([]), plt .yticks ([])
179- plt .xlim (- 0.25 , 10 * np .pi + .25 )
180+ plt .xlim (- 0.25 , 10 * np .pi + 0 .25 )
180181plt .ylim (- 1.5 , 1.5 )
181182plt .tight_layout ()
182183plt .savefig ("../figures/tip-multiline.pdf" , dpi = 100 )
183184
184185
185186# outline
186187# -----------------------------------------------------------------------------
187- fig = plt .figure (figsize = (2 ,2 ))
188-
188+ fig = plt .figure (figsize = (2 , 2 ))
189189ax = fig .add_axes (rect , xticks = [], yticks = [])
190190
191191np .random .seed (1 )
192- Z = np .random .uniform (0 ,1 , (8 ,8 ))
192+ Z = np .random .uniform (0 , 1 , (8 , 8 ))
193193cmap = plt .get_cmap ("Oranges" )
194194ax .imshow (Z , interpolation = "nearest" , cmap = cmap , vmin = 0 , vmax = 2 )
195195
@@ -208,8 +208,8 @@ def setup(ax):
208208np .random .seed (5 )
209209X = np .random .normal (0 , 0.25 , n )
210210Y = np .random .normal (0 , 0.25 , n )
211- ax .scatter (X , Y , s = 50 , c = "k" , lw = 2 )
212- ax .scatter (X , Y , s = 50 , c = "w" , lw = 0 )
211+ ax .scatter (X , Y , s = 50 , c = "k" , lw = 2 )
212+ ax .scatter (X , Y , s = 50 , c = "w" , lw = 0 )
213213ax .scatter (X , Y , s = 40 , c = "C1" , lw = 0 , alpha = 0.1 )
214214
215215ax .set_xlim ([- 1 , 1 ]), ax .set_xticks ([]),
0 commit comments