18
18
19
19
# color range
20
20
# -----------------------------------------------------------------------------
21
- fig = plt .figure (figsize = (2 ,2 ))
21
+ fig = plt .figure (figsize = (2 , 2 ))
22
22
ax = fig .add_axes (rect , xticks = [], yticks = [])
23
23
24
- X = np .random .seed (1 )
24
+ np .random .seed (1 )
25
25
X = np .random .randn (1000 , 4 )
26
26
cmap = 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 ]]
28
28
ax .hist (X , 2 , density = True , histtype = 'bar' , color = colors )
29
29
30
30
plt .savefig ("../figures/tip-color-range.pdf" )
31
31
32
32
33
33
# colorbar
34
34
# -----------------------------------------------------------------------------
35
- fig = plt .figure (figsize = (2.15 ,2 ))
35
+ fig = plt .figure (figsize = (2.15 , 2 ))
36
36
ax = fig .add_axes (rect , xticks = [], yticks = [])
37
37
38
38
np .random .seed (1 )
39
- Z = np .random .uniform (0 ,1 , (8 ,8 ))
39
+ Z = np .random .uniform (0 , 1 , (8 , 8 ))
40
40
cmap = plt .get_cmap ("Oranges" )
41
41
im = ax .imshow (Z , interpolation = "nearest" , cmap = cmap , vmin = 0 , vmax = 2 )
42
42
cb = fig .colorbar (im , fraction = 0.046 , pad = 0.04 )
47
47
48
48
# dotted
49
49
# -----------------------------------------------------------------------------
50
- fig = plt .figure (figsize = (5 ,.25 ))
50
+ fig = plt .figure (figsize = (5 , 0 .25 ))
51
51
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
+ )
54
55
55
56
epsilon = 1e-12
56
57
plt .plot ([0 ,1 ], [0 ,0 ], "black" , clip_on = False , lw = 8 ,
62
63
63
64
# dual axis
64
65
# -----------------------------------------------------------------------------
65
- fig = plt .figure (figsize = (2 ,2 ))
66
+ fig = plt .figure (figsize = (2 , 2 ))
66
67
ax1 = fig .add_axes (rect , label = "cartesian" )
67
68
ax2 = fig .add_axes (rect , projection = "polar" , label = "polar" )
68
69
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))
71
72
72
73
ax2 .set_rorigin (0 )
73
74
ax2 .set_thetamax (90 )
74
- ax2 .set_ylim (0.5 ,1.0 )
75
+ ax2 .set_ylim (0.5 , 1.0 )
75
76
ax2 .set_xticks (np .linspace (0 , np .pi / 2 , 10 ))
76
77
ax2 .set_yticks (np .linspace (0.5 , 1.0 , 5 ))
77
78
@@ -103,7 +104,7 @@ def setup(ax):
103
104
ax .patch .set_alpha (0.0 )
104
105
105
106
106
- fig = plt .figure (figsize = (5 , .5 ))
107
+ fig = plt .figure (figsize = (5 , 0 .5 ))
107
108
fig .patch .set_alpha (0.0 )
108
109
n = 1
109
110
@@ -132,27 +133,27 @@ def setup(ax):
132
133
plt .rcParams ['hatch.color' ] = color1
133
134
plt .rcParams ['hatch.linewidth' ] = 8
134
135
135
- fig = plt .figure (figsize = (2 ,2 ))
136
+ fig = plt .figure (figsize = (2 , 2 ))
136
137
ax = plt .subplot ()
137
138
np .random .seed (123 )
138
139
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 )
141
142
142
143
ax .bar (x1 , y1 , color = color2 )
143
144
for i in range (len (x1 )):
144
145
plt .annotate ("%d%%" % y1 [i ], (x1 [i ], y1 [i ]), xytext = (0 ,1 ),
145
146
fontsize = "x-small" , color = color2 ,
146
147
textcoords = "offset points" , va = "bottom" , ha = "center" )
147
148
148
- ax .bar (x2 , y2 , color = color2 , hatch = "/" )
149
+ ax .bar (x2 , y2 , color = color2 , hatch = "/" )
149
150
for i in range (len (x2 )):
150
151
plt .annotate ("%d%%" % y2 [i ], (x2 [i ], y2 [i ]), xytext = (0 ,1 ),
151
152
fontsize = "x-small" , color = color2 ,
152
153
textcoords = "offset points" , va = "bottom" , ha = "center" )
153
154
154
155
ax .set_yticks ([])
155
- ax .set_xticks (0.5 + np .arange (0 ,6 , 3 ))
156
+ ax .set_xticks (0.5 + np .arange (0 , 6 , 3 ))
156
157
ax .set_xticklabels (["2018" , "2019" ])
157
158
ax .tick_params ('x' , length = 0 , labelsize = "small" , which = 'major' )
158
159
@@ -166,30 +167,29 @@ def setup(ax):
166
167
167
168
# multiline
168
169
# -----------------------------------------------------------------------------
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
171
172
ax = fig .add_axes ([dx , dy , 1 - 2 * dx , 1 - 2 * dy ], frameon = False )
172
- X ,Y = [], []
173
+ X , Y = [], []
173
174
for x in np .linspace (0.01 , 10 * np .pi - 0.01 , 100 ):
174
- X .extend ([x , x ,None ])
175
+ X .extend ([x , x , None ])
175
176
Y .extend ([0 , np .sin (x ), None ])
176
177
print (X [:10 ], Y [:10 ])
177
178
plt .plot (X , Y , "black" )
178
179
plt .xticks ([]), plt .yticks ([])
179
- plt .xlim (- 0.25 , 10 * np .pi + .25 )
180
+ plt .xlim (- 0.25 , 10 * np .pi + 0 .25 )
180
181
plt .ylim (- 1.5 , 1.5 )
181
182
plt .tight_layout ()
182
183
plt .savefig ("../figures/tip-multiline.pdf" , dpi = 100 )
183
184
184
185
185
186
# outline
186
187
# -----------------------------------------------------------------------------
187
- fig = plt .figure (figsize = (2 ,2 ))
188
-
188
+ fig = plt .figure (figsize = (2 , 2 ))
189
189
ax = fig .add_axes (rect , xticks = [], yticks = [])
190
190
191
191
np .random .seed (1 )
192
- Z = np .random .uniform (0 ,1 , (8 ,8 ))
192
+ Z = np .random .uniform (0 , 1 , (8 , 8 ))
193
193
cmap = plt .get_cmap ("Oranges" )
194
194
ax .imshow (Z , interpolation = "nearest" , cmap = cmap , vmin = 0 , vmax = 2 )
195
195
@@ -208,8 +208,8 @@ def setup(ax):
208
208
np .random .seed (5 )
209
209
X = np .random .normal (0 , 0.25 , n )
210
210
Y = 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 )
213
213
ax .scatter (X , Y , s = 40 , c = "C1" , lw = 0 , alpha = 0.1 )
214
214
215
215
ax .set_xlim ([- 1 , 1 ]), ax .set_xticks ([]),
0 commit comments