-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_export_submission.py
More file actions
93 lines (75 loc) · 2.93 KB
/
06_export_submission.py
File metadata and controls
93 lines (75 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
Batch export — write a figure in multiple formats for journal submission.
Steps:
1. Create a figure with plotstyle.use() and plotstyle.figure().
2. Call plotstyle.export_submission() to write the figure in journal-preferred formats.
Pass author_surname for journals (e.g. IEEE) that require author-prefix filenames.
Output:
output/submission_nature/ — Nature preferred formats
output/submission_ieee/ — IEEE with "smit_" author prefix
output/submission_science/ — Science with explicit format override
"""
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import plotstyle
OUTPUT_DIR = Path(__file__).parent / "output"
OUTPUT_DIR.mkdir(exist_ok=True)
# ==============================================================================
# 1. Nature — uses the journal's preferred formats automatically
# ==============================================================================
with plotstyle.use("nature") as style:
fig, ax = style.figure(columns=1)
x = np.linspace(0, 4 * np.pi, 200)
ax.plot(x, np.exp(-x / 10) * np.sin(x))
ax.set_xlabel("Time (s)")
ax.set_ylabel("Amplitude")
# When formats= is omitted, preferred_formats from the Nature spec are used.
paths = style.export_submission(
fig,
"fig1",
output_dir=OUTPUT_DIR / "submission_nature",
)
print("Nature submission files:")
for p in paths:
print(f" {p}")
plt.close(fig)
# ==============================================================================
# 2. IEEE — author-surname prefix for filename compliance
# ==============================================================================
with plotstyle.use("ieee") as style:
fig, ax = style.figure(columns=1)
categories = ["Method A", "Method B", "Method C"]
accuracy = [92.3, 95.1, 88.7]
ax.bar(categories, accuracy)
ax.set_ylabel("Accuracy (%)")
# author_surname triggers IEEE naming: "smith_fig2.pdf" (first 5 chars of surname)
paths = style.export_submission(
fig,
"fig2",
author_surname="Smith",
output_dir=OUTPUT_DIR / "submission_ieee",
)
print("\nIEEE submission files:")
for p in paths:
print(f" {p}")
plt.close(fig)
# ==============================================================================
# 3. Science — explicit format list overrides the spec
# ==============================================================================
with plotstyle.use("science") as style:
fig, ax = style.figure(columns=1)
ax.plot([0, 1, 2], [1, 3, 2])
ax.set_xlabel("x")
ax.set_ylabel("y")
# formats= takes priority over the spec's preferred_formats
paths = style.export_submission(
fig,
"supplementary_fig",
formats=["pdf", "png"],
output_dir=OUTPUT_DIR / "submission_science",
)
print("\nScience submission files (custom formats):")
for p in paths:
print(f" {p}")
plt.close(fig)