Skip to content

Commit 0bb0dc7

Browse files
committed
Improve examples: delete pdfs, tweak example.py
Delete PDF output to have a cleaner figures folder
1 parent 337e87a commit 0bb0dc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+43
-30
lines changed

examples/figures/fig01.jpg

63.2 KB

examples/figures/fig02a.jpg

51.6 KB

examples/figures/fig02b.jpg

55.1 KB

examples/figures/fig02c.jpg

53 KB

examples/figures/fig03.jpg

76.6 KB

examples/figures/fig04.jpg

64 KB

examples/figures/fig05.jpg

62.6 KB

examples/figures/fig06.jpg

65.3 KB

examples/figures/fig07.jpg

67.9 KB

examples/figures/fig08.jpg

70.9 KB

examples/figures/fig09.jpg

60.2 KB

examples/figures/fig1.jpg

-111 KB
Binary file not shown.

examples/figures/fig1.pdf

-72.2 KB
Binary file not shown.

examples/figures/fig10.jpg

-123 KB

examples/figures/fig10.pdf

-17.8 KB
Binary file not shown.

examples/figures/fig11.jpg

-66.4 KB

examples/figures/fig11.pdf

-72.5 KB
Binary file not shown.

examples/figures/fig12.jpg

-37.7 KB

examples/figures/fig12.pdf

-71.2 KB
Binary file not shown.

examples/figures/fig13.jpg

-53.6 KB

examples/figures/fig13.pdf

-104 KB
Binary file not shown.

examples/figures/fig16.jpg

-62.7 KB

examples/figures/fig17.jpg

6.83 KB

examples/figures/fig2a.jpg

-89.5 KB
Binary file not shown.

examples/figures/fig2a.pdf

-85.3 KB
Binary file not shown.

examples/figures/fig2b.jpg

-95.6 KB
Binary file not shown.

examples/figures/fig2b.pdf

-86 KB
Binary file not shown.

examples/figures/fig2c.jpg

-92.6 KB
Binary file not shown.

examples/figures/fig2c.pdf

-85.1 KB
Binary file not shown.

examples/figures/fig3.jpg

-133 KB
Binary file not shown.

examples/figures/fig3.pdf

-284 KB
Binary file not shown.

examples/figures/fig4.jpg

-116 KB
Binary file not shown.

examples/figures/fig4.pdf

-72.3 KB
Binary file not shown.

examples/figures/fig5.jpg

-114 KB
Binary file not shown.

examples/figures/fig5.pdf

-72.3 KB
Binary file not shown.

examples/figures/fig6.jpg

-117 KB
Binary file not shown.

examples/figures/fig6.pdf

-72.5 KB
Binary file not shown.

examples/figures/fig7.jpg

-122 KB
Binary file not shown.

examples/figures/fig7.pdf

-72.5 KB
Binary file not shown.

examples/figures/fig8.jpg

-129 KB
Binary file not shown.

examples/figures/fig8.pdf

-104 KB
Binary file not shown.

examples/figures/fig9.jpg

-106 KB
Binary file not shown.

examples/figures/fig9.pdf

-72.2 KB
Binary file not shown.

examples/plot-examples.py

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
import matplotlib.pyplot as plt
55
import scienceplots
66

7+
import os
8+
9+
# Check we are in examples dir
10+
current_dir = os.getcwd().lower()
11+
if (current_dir.endswith('scienceplots')):
12+
os.chdir('./examples')
13+
# Create 'figures' folder if it does not exist
14+
if (not os.path.exists('./figures')):
15+
os.makedirs('figures')
16+
717
def model(x, p):
818
return x ** (2 * p + 1) / (1 + x ** (2 * p))
919

@@ -19,8 +29,8 @@ def model(x, p):
1929
ax.legend(title='Order')
2030
ax.autoscale(tight=True)
2131
ax.set(**pparam)
22-
fig.savefig('figures/fig1.pdf')
23-
fig.savefig('figures/fig1.jpg', dpi=300)
32+
fig.savefig('figures/fig01.jpg', dpi=300)
33+
plt.close()
2434

2535
with plt.style.context(['science', 'ieee']):
2636
fig, ax = plt.subplots()
@@ -29,10 +39,8 @@ def model(x, p):
2939
ax.legend(title='Order')
3040
ax.autoscale(tight=True)
3141
ax.set(**pparam)
32-
# Note: $\mu$ doesn't work with Times font (used by ieee style)
33-
ax.set_ylabel(r'Current (\textmu A)')
34-
fig.savefig('figures/fig2a.pdf')
35-
fig.savefig('figures/fig2a.jpg', dpi=300)
42+
fig.savefig('figures/fig02a.jpg', dpi=300)
43+
plt.close()
3644

3745
with plt.style.context(['science', 'ieee', 'std-colors']):
3846
fig, ax = plt.subplots()
@@ -41,10 +49,8 @@ def model(x, p):
4149
ax.legend(title='Order')
4250
ax.autoscale(tight=True)
4351
ax.set(**pparam)
44-
# Note: $\mu$ doesn't work with Times font (used by ieee style)
45-
ax.set_ylabel(r'Current (\textmu A)')
46-
fig.savefig('figures/fig2b.pdf')
47-
fig.savefig('figures/fig2b.jpg', dpi=300)
52+
fig.savefig('figures/fig02b.jpg', dpi=300)
53+
plt.close()
4854

4955
with plt.style.context(['science', 'nature']):
5056
fig, ax = plt.subplots()
@@ -53,8 +59,8 @@ def model(x, p):
5359
ax.legend(title='Order')
5460
ax.autoscale(tight=True)
5561
ax.set(**pparam)
56-
fig.savefig('figures/fig2c.pdf')
57-
fig.savefig('figures/fig2c.jpg', dpi=300)
62+
fig.savefig('figures/fig02c.jpg', dpi=300)
63+
plt.close()
5864

5965
with plt.style.context(['science', 'scatter']):
6066
fig, ax = plt.subplots(figsize=(4, 4))
@@ -73,8 +79,8 @@ def model(x, p):
7379
ax.set_ylabel(ylbl)
7480
ax.set_xlim([-2, 2])
7581
ax.set_ylim([-2, 2])
76-
fig.savefig('figures/fig3.pdf')
77-
fig.savefig('figures/fig3.jpg', dpi=300)
82+
fig.savefig('figures/fig03.jpg', dpi=300)
83+
plt.close()
7884

7985
with plt.style.context(['science', 'high-vis']):
8086
fig, ax = plt.subplots()
@@ -83,8 +89,8 @@ def model(x, p):
8389
ax.legend(title='Order')
8490
ax.autoscale(tight=True)
8591
ax.set(**pparam)
86-
fig.savefig('figures/fig4.pdf')
87-
fig.savefig('figures/fig4.jpg', dpi=300)
92+
fig.savefig('figures/fig04.jpg', dpi=300)
93+
plt.close()
8894

8995
with plt.style.context(['dark_background', 'science', 'high-vis']):
9096
fig, ax = plt.subplots()
@@ -93,8 +99,8 @@ def model(x, p):
9399
ax.legend(title='Order')
94100
ax.autoscale(tight=True)
95101
ax.set(**pparam)
96-
fig.savefig('figures/fig5.pdf')
97-
fig.savefig('figures/fig5.jpg', dpi=300)
102+
fig.savefig('figures/fig05.jpg', dpi=300)
103+
plt.close()
98104

99105
with plt.style.context(['science', 'notebook']):
100106
fig, ax = plt.subplots()
@@ -103,8 +109,8 @@ def model(x, p):
103109
ax.legend(title='Order')
104110
ax.autoscale(tight=True)
105111
ax.set(**pparam)
106-
fig.savefig('figures/fig10.pdf')
107112
fig.savefig('figures/fig10.jpg', dpi=300)
113+
plt.close()
108114

109115
# Plot different color cycles
110116

@@ -115,8 +121,8 @@ def model(x, p):
115121
ax.legend(title='Order')
116122
ax.autoscale(tight=True)
117123
ax.set(**pparam)
118-
fig.savefig('figures/fig6.pdf')
119-
fig.savefig('figures/fig6.jpg', dpi=300)
124+
fig.savefig('figures/fig06.jpg', dpi=300)
125+
plt.close()
120126

121127
with plt.style.context(['science', 'vibrant']):
122128
fig, ax = plt.subplots()
@@ -125,8 +131,8 @@ def model(x, p):
125131
ax.legend(title='Order')
126132
ax.autoscale(tight=True)
127133
ax.set(**pparam)
128-
fig.savefig('figures/fig7.pdf')
129-
fig.savefig('figures/fig7.jpg', dpi=300)
134+
fig.savefig('figures/fig07.jpg', dpi=300)
135+
plt.close()
130136

131137
with plt.style.context(['science', 'muted']):
132138
fig, ax = plt.subplots()
@@ -135,8 +141,8 @@ def model(x, p):
135141
ax.legend(title='Order', fontsize=7)
136142
ax.autoscale(tight=True)
137143
ax.set(**pparam)
138-
fig.savefig('figures/fig8.pdf')
139-
fig.savefig('figures/fig8.jpg', dpi=300)
144+
fig.savefig('figures/fig08.jpg', dpi=300)
145+
plt.close()
140146

141147
with plt.style.context(['science', 'retro']):
142148
fig, ax = plt.subplots()
@@ -145,8 +151,8 @@ def model(x, p):
145151
ax.legend(title='Order')
146152
ax.autoscale(tight=True)
147153
ax.set(**pparam)
148-
fig.savefig('figures/fig9.pdf')
149-
fig.savefig('figures/fig9.jpg', dpi=300)
154+
fig.savefig('figures/fig09.jpg', dpi=300)
155+
plt.close()
150156

151157
with plt.style.context(['science', 'grid']):
152158
fig, ax = plt.subplots()
@@ -155,8 +161,8 @@ def model(x, p):
155161
ax.legend(title='Order')
156162
ax.autoscale(tight=True)
157163
ax.set(**pparam)
158-
fig.savefig('figures/fig11.pdf')
159164
fig.savefig('figures/fig11.jpg', dpi=300)
165+
plt.close()
160166

161167
with plt.style.context(['science', 'high-contrast']):
162168
fig, ax = plt.subplots()
@@ -165,8 +171,8 @@ def model(x, p):
165171
ax.legend(title='Order')
166172
ax.autoscale(tight=True)
167173
ax.set(**pparam)
168-
fig.savefig('figures/fig12.pdf')
169174
fig.savefig('figures/fig12.jpg', dpi=300)
175+
plt.close()
170176

171177
with plt.style.context(['science', 'light']):
172178
fig, ax = plt.subplots()
@@ -175,8 +181,8 @@ def model(x, p):
175181
ax.legend(title='Order', fontsize=7)
176182
ax.autoscale(tight=True)
177183
ax.set(**pparam)
178-
fig.savefig('figures/fig13.pdf')
179184
fig.savefig('figures/fig13.jpg', dpi=300)
185+
plt.close()
180186

181187
# Note: You need to install the Noto Serif CJK Fonts before running
182188
# examples 14 and 15. See FAQ in README.
@@ -190,6 +196,7 @@ def model(x, p):
190196
ax.set(ylabel=r'電流 ($\mu$A)')
191197
ax.autoscale(tight=True)
192198
fig.savefig('figures/fig14a.jpg', dpi=300)
199+
plt.close()
193200

194201
with plt.style.context(['science', 'no-latex', 'cjk-sc-font']):
195202
fig, ax = plt.subplots()
@@ -200,6 +207,7 @@ def model(x, p):
200207
ax.set(ylabel=r'电流 ($\mu$A)')
201208
ax.autoscale(tight=True)
202209
fig.savefig('figures/fig14b.jpg', dpi=300)
210+
plt.close()
203211

204212
with plt.style.context(['science', 'no-latex', 'cjk-jp-font']):
205213
fig, ax = plt.subplots()
@@ -210,6 +218,7 @@ def model(x, p):
210218
ax.set(ylabel=r'電気 ($\mu$A)')
211219
ax.autoscale(tight=True)
212220
fig.savefig('figures/fig14c.jpg', dpi=300)
221+
plt.close()
213222

214223
with plt.style.context(['science', 'no-latex', 'cjk-kr-font']):
215224
fig, ax = plt.subplots()
@@ -220,6 +229,7 @@ def model(x, p):
220229
ax.set(ylabel=r'전류 ($\mu$A)')
221230
ax.autoscale(tight=True)
222231
fig.savefig('figures/fig14d.jpg', dpi=300)
232+
plt.close()
223233

224234
# import matplotlib
225235
# matplotlib.use('pgf') # stwich backend to pgf
@@ -243,6 +253,7 @@ def model(x, p):
243253
# ax.set(ylabel=r'電流 ($\mu$A)')
244254
# ax.autoscale(tight=True)
245255
# fig.savefig('figures/fig15.pdf', backend='pgf')
256+
# plt.close()
246257

247258
with plt.style.context(['science', 'russian-font']):
248259
fig, ax = plt.subplots()
@@ -253,6 +264,7 @@ def model(x, p):
253264
ax.set(ylabel=r'Сила тока ($\mu$A)')
254265
ax.autoscale(tight=True)
255266
fig.savefig('figures/fig16.jpg', dpi=300)
267+
plt.close()
256268

257269
with plt.style.context(['science', 'turkish-font']):
258270
fig, ax = plt.subplots()
@@ -263,3 +275,4 @@ def model(x, p):
263275
ax.set(ylabel=r'Mevcut Güç/Akım ($\mu$A)')
264276
ax.autoscale(tight=True)
265277
fig.savefig('figures/fig17.jpg', dpi=300)
278+
plt.close()

0 commit comments

Comments
 (0)