Skip to content

Commit fa241e2

Browse files
committed
fix whitespace and other formatting
1 parent 97a5b90 commit fa241e2

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

scripts/tips.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@
1818

1919
# color range
2020
# -----------------------------------------------------------------------------
21-
fig = plt.figure(figsize=(2,2))
21+
fig = plt.figure(figsize=(2, 2))
2222
ax = fig.add_axes(rect, xticks=[], yticks=[])
2323

24-
X = np.random.seed(1)
24+
np.random.seed(1)
2525
X = np.random.randn(1000, 4)
2626
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]]
2828
ax.hist(X, 2, density=True, histtype='bar', color=colors)
2929

3030
plt.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))
3636
ax = fig.add_axes(rect, xticks=[], yticks=[])
3737

3838
np.random.seed(1)
39-
Z = np.random.uniform(0,1,(8,8))
39+
Z = np.random.uniform(0, 1, (8, 8))
4040
cmap = plt.get_cmap("Oranges")
4141
im = ax.imshow(Z, interpolation="nearest", cmap=cmap, vmin=0, vmax=2)
4242
cb = fig.colorbar(im, fraction=0.046, pad=0.04)
@@ -47,10 +47,11 @@
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

5556
epsilon=1e-12
5657
plt.plot([0,1], [0,0], "black", clip_on=False, lw=8,
@@ -62,16 +63,16 @@
6263

6364
# dual axis
6465
# -----------------------------------------------------------------------------
65-
fig = plt.figure(figsize=(2,2))
66+
fig = plt.figure(figsize=(2, 2))
6667
ax1 = fig.add_axes(rect, label="cartesian")
6768
ax2 = 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

7273
ax2.set_rorigin(0)
7374
ax2.set_thetamax(90)
74-
ax2.set_ylim(0.5,1.0)
75+
ax2.set_ylim(0.5, 1.0)
7576
ax2.set_xticks(np.linspace(0, np.pi/2, 10))
7677
ax2.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))
107108
fig.patch.set_alpha(0.0)
108109
n = 1
109110

@@ -132,27 +133,27 @@ def setup(ax):
132133
plt.rcParams['hatch.color'] = color1
133134
plt.rcParams['hatch.linewidth'] = 8
134135

135-
fig = plt.figure(figsize=(2,2))
136+
fig = plt.figure(figsize=(2, 2))
136137
ax = plt.subplot()
137138
np.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

142143
ax.bar(x1, y1, color=color2)
143144
for 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="/")
149150
for 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

154155
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))
156157
ax.set_xticklabels(["2018", "2019"])
157158
ax.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
171172
ax = fig.add_axes([dx, dy, 1-2*dx, 1-2*dy], frameon=False)
172-
X,Y = [], []
173+
X, Y = [], []
173174
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])
175176
Y.extend([0, np.sin(x), None])
176177
print(X[:10], Y[:10])
177178
plt.plot(X, Y, "black")
178179
plt.xticks([]), plt.yticks([])
179-
plt.xlim(-0.25, 10*np.pi+.25)
180+
plt.xlim(-0.25, 10*np.pi+0.25)
180181
plt.ylim(-1.5, 1.5)
181182
plt.tight_layout()
182183
plt.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))
189189
ax = fig.add_axes(rect, xticks=[], yticks=[])
190190

191191
np.random.seed(1)
192-
Z = np.random.uniform(0,1,(8,8))
192+
Z = np.random.uniform(0, 1, (8, 8))
193193
cmap = plt.get_cmap("Oranges")
194194
ax.imshow(Z, interpolation="nearest", cmap=cmap, vmin=0, vmax=2)
195195

@@ -208,8 +208,8 @@ def setup(ax):
208208
np.random.seed(5)
209209
X = np.random.normal(0, 0.25, n)
210210
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)
213213
ax.scatter(X, Y, s=40, c="C1", lw=0, alpha=0.1)
214214

215215
ax.set_xlim([-1, 1]), ax.set_xticks([]),

0 commit comments

Comments
 (0)