Skip to content

Commit

Permalink
Improve examples: delete pdfs, tweak example.py
Browse files Browse the repository at this point in the history
Delete PDF output to have a cleaner figures folder
  • Loading branch information
echedey-ls committed May 30, 2023
1 parent 337e87a commit 0bb0dc7
Show file tree
Hide file tree
Showing 44 changed files with 43 additions and 30 deletions.
Binary file added examples/figures/fig01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig02a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig02b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig02c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig04.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig05.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig06.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig07.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig08.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figures/fig09.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig1.jpg
Binary file not shown.
Binary file removed examples/figures/fig1.pdf
Binary file not shown.
Binary file modified examples/figures/fig10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig10.pdf
Binary file not shown.
Binary file modified examples/figures/fig11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig11.pdf
Binary file not shown.
Binary file modified examples/figures/fig12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig12.pdf
Binary file not shown.
Binary file modified examples/figures/fig13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig13.pdf
Binary file not shown.
Binary file modified examples/figures/fig16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/figures/fig2a.jpg
Binary file not shown.
Binary file removed examples/figures/fig2a.pdf
Binary file not shown.
Binary file removed examples/figures/fig2b.jpg
Binary file not shown.
Binary file removed examples/figures/fig2b.pdf
Binary file not shown.
Binary file removed examples/figures/fig2c.jpg
Binary file not shown.
Binary file removed examples/figures/fig2c.pdf
Binary file not shown.
Binary file removed examples/figures/fig3.jpg
Binary file not shown.
Binary file removed examples/figures/fig3.pdf
Binary file not shown.
Binary file removed examples/figures/fig4.jpg
Binary file not shown.
Binary file removed examples/figures/fig4.pdf
Binary file not shown.
Binary file removed examples/figures/fig5.jpg
Binary file not shown.
Binary file removed examples/figures/fig5.pdf
Binary file not shown.
Binary file removed examples/figures/fig6.jpg
Binary file not shown.
Binary file removed examples/figures/fig6.pdf
Binary file not shown.
Binary file removed examples/figures/fig7.jpg
Diff not rendered.
Binary file removed examples/figures/fig7.pdf
Binary file not shown.
Binary file removed examples/figures/fig8.jpg
Diff not rendered.
Binary file removed examples/figures/fig8.pdf
Binary file not shown.
Binary file removed examples/figures/fig9.jpg
Diff not rendered.
Binary file removed examples/figures/fig9.pdf
Binary file not shown.
73 changes: 43 additions & 30 deletions examples/plot-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
import matplotlib.pyplot as plt
import scienceplots

import os

# Check we are in examples dir
current_dir = os.getcwd().lower()
if (current_dir.endswith('scienceplots')):
os.chdir('./examples')
# Create 'figures' folder if it does not exist
if (not os.path.exists('./figures')):
os.makedirs('figures')

def model(x, p):
return x ** (2 * p + 1) / (1 + x ** (2 * p))

Expand All @@ -19,8 +29,8 @@ def model(x, p):
ax.legend(title='Order')
ax.autoscale(tight=True)
ax.set(**pparam)
fig.savefig('figures/fig1.pdf')
fig.savefig('figures/fig1.jpg', dpi=300)
fig.savefig('figures/fig01.jpg', dpi=300)
plt.close()

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

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

with plt.style.context(['science', 'nature']):
fig, ax = plt.subplots()
Expand All @@ -53,8 +59,8 @@ def model(x, p):
ax.legend(title='Order')
ax.autoscale(tight=True)
ax.set(**pparam)
fig.savefig('figures/fig2c.pdf')
fig.savefig('figures/fig2c.jpg', dpi=300)
fig.savefig('figures/fig02c.jpg', dpi=300)
plt.close()

with plt.style.context(['science', 'scatter']):
fig, ax = plt.subplots(figsize=(4, 4))
Expand All @@ -73,8 +79,8 @@ def model(x, p):
ax.set_ylabel(ylbl)
ax.set_xlim([-2, 2])
ax.set_ylim([-2, 2])
fig.savefig('figures/fig3.pdf')
fig.savefig('figures/fig3.jpg', dpi=300)
fig.savefig('figures/fig03.jpg', dpi=300)
plt.close()

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

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

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

# Plot different color cycles

Expand All @@ -115,8 +121,8 @@ def model(x, p):
ax.legend(title='Order')
ax.autoscale(tight=True)
ax.set(**pparam)
fig.savefig('figures/fig6.pdf')
fig.savefig('figures/fig6.jpg', dpi=300)
fig.savefig('figures/fig06.jpg', dpi=300)
plt.close()

with plt.style.context(['science', 'vibrant']):
fig, ax = plt.subplots()
Expand All @@ -125,8 +131,8 @@ def model(x, p):
ax.legend(title='Order')
ax.autoscale(tight=True)
ax.set(**pparam)
fig.savefig('figures/fig7.pdf')
fig.savefig('figures/fig7.jpg', dpi=300)
fig.savefig('figures/fig07.jpg', dpi=300)
plt.close()

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

with plt.style.context(['science', 'retro']):
fig, ax = plt.subplots()
Expand All @@ -145,8 +151,8 @@ def model(x, p):
ax.legend(title='Order')
ax.autoscale(tight=True)
ax.set(**pparam)
fig.savefig('figures/fig9.pdf')
fig.savefig('figures/fig9.jpg', dpi=300)
fig.savefig('figures/fig09.jpg', dpi=300)
plt.close()

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

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

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

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

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

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

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

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

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

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

0 comments on commit 0bb0dc7

Please sign in to comment.