Skip to content

Commit

Permalink
Merge pull request #94 from daavid00/fixLaTeX
Browse files Browse the repository at this point in the history
Make optional to use LaTeX
  • Loading branch information
daavid00 authored Dec 2, 2024
2 parents e1385e2 + 4232e39 commit 3d24699
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/pyopmspe11/core/pyopmspe11.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def pyopmspe11():
cmdargs["write"].strip()
) # Temporal resolution to write the sparse and performance data
dic["showpywarn"] = int(cmdargs["showpywarn"]) # Show or hidde python warnings
dic["latex"] = int(cmdargs["latex"]) # LaTeX formatting
if dic["showpywarn"] != 1:
warnings.warn = lambda *args, **kwargs: None
# If the compare plots are generated, then we exit right afterwards
Expand Down Expand Up @@ -164,6 +165,12 @@ def load_parser():
default=0,
help="Set to 1 to show Python warnings ('0' by default).",
)
parser.add_argument(
"-l",
"--latex",
default=1,
help="Set to 0 to not use LaTeX formatting ('1' by default).",
)
return vars(parser.parse_known_args()[0])


Expand Down
1 change: 1 addition & 0 deletions src/pyopmspe11/utils/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def plotting(dic):
"-g " + f"{dic['generate']}",
"-r " + f"{dic['resolution']}",
"-s " + f"{dic['showpywarn']}",
"-l " + f"{dic['latex']}",
]
print(" ".join(plot_exe))
prosc = subprocess.run(plot_exe, check=True)
Expand Down
33 changes: 20 additions & 13 deletions src/pyopmspe11/visualization/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@

font = {"family": "normal", "weight": "normal", "size": 20}
matplotlib.rc("font", **font)
plt.rcParams.update(
{
"text.usetex": True,
"font.family": "monospace",
"legend.columnspacing": 0.9,
"legend.handlelength": 3.5,
"legend.fontsize": 15,
"lines.linewidth": 4,
"axes.titlesize": 20,
"axes.grid": True,
"figure.figsize": (10, 5),
}
)

SECONDS_IN_YEAR = 31536000.0

Expand Down Expand Up @@ -69,13 +56,20 @@ def main():
default=0,
help="Set to 1 to show Python warnings ('0' by default).",
)
parser.add_argument(
"-l",
"--latex",
default=1,
help="Set to 0 to not use LaTeX formatting ('1' by default).",
)
cmdargs = vars(parser.parse_known_args()[0])
if int(cmdargs["showpywarn"]) != 1: # Show or hidde python warnings
warnings.warn = lambda *args, **kwargs: None
dic = {"folders": [cmdargs["folder"].strip()]}
dic["case"] = cmdargs["deck"].strip()
dic["generate"] = cmdargs["generate"].strip()
dic["compare"] = cmdargs["compare"] # No empty, then the create compare folder
dic["latex"] = int(cmdargs["latex"]) # LaTeX formatting
dic["exe"] = os.getcwd() # Path to the folder of the configuration file
plot_results(dic)

Expand All @@ -91,6 +85,19 @@ def plot_results(dic):
None
"""
plt.rcParams.update(
{
"text.usetex": dic["latex"] not in [0],
"font.family": "monospace",
"legend.columnspacing": 0.9,
"legend.handlelength": 3.5,
"legend.fontsize": 15,
"lines.linewidth": 4,
"axes.titlesize": 20,
"axes.grid": True,
"figure.figsize": (10, 5),
}
)
dic["colors"] = [
"#1f77b4",
"#ff7f0e",
Expand Down

0 comments on commit 3d24699

Please sign in to comment.