From 2b050fad129a392697a214046baf2de889b1e7d8 Mon Sep 17 00:00:00 2001
From: Felix Fischer <f.fischer@ifas.rwth-aachen.de>
Date: Thu, 6 Jun 2024 15:44:09 +0200
Subject: [PATCH] Added option to only a create a single plot as preview.

---
 readme.md                             | 9 +++++++++
 src/scientific_plots/__init__.py      | 2 +-
 src/scientific_plots/plot_settings.py | 7 +++++++
 src/scientific_plots/utilities.py     | 4 +++-
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/readme.md b/readme.md
index 79a6422..36e39c1 100644
--- a/readme.md
+++ b/readme.md
@@ -93,6 +93,15 @@ All of those functions have the following command-line arguments:
 - `xlim`: Set the limits on the x-axis manually.
 - `ylim`: Set the limits on the y-axis manually.
 
+### Preview-Mode
+It is possible to only create a single plot for every called plot function
+to save computation time. This 'preview' mode can be called by setting the
+following global variable in `scientific_plots.plot_settings` to true:
+```
+import scientifc_plots.plot_settings
+scientifc_plots.plot_settings.PREVIEW = True
+```
+
 ## Types
 Additional Vector like types for numpy-arrays are provided in
 `scientifc_plots.types_`.  These types can be used for static type checking
diff --git a/src/scientific_plots/__init__.py b/src/scientific_plots/__init__.py
index 76e0535..896a8d8 100644
--- a/src/scientific_plots/__init__.py
+++ b/src/scientific_plots/__init__.py
@@ -5,4 +5,4 @@ useful across several different projects and repositories. It also contains
 stub-files with several data-type annotations for scipy and matplot-lib
 functions."""
 
-__version__ = "1.8.2"
+__version__ = "1.8.3"
diff --git a/src/scientific_plots/plot_settings.py b/src/scientific_plots/plot_settings.py
index ed49b62..89a5e64 100644
--- a/src/scientific_plots/plot_settings.py
+++ b/src/scientific_plots/plot_settings.py
@@ -38,6 +38,9 @@ SPINE_COLOR = "black"
 FIGSIZE = (3.15, 2.35)
 FIGSIZE_SLIM = (3.15, 2.1)
 FIGSIZE_SMALL = (2.2, 2.1)
+
+PREVIEW = False  # Generate only one set of plots, don't create the whole set
+
 _savefig = copy(plt.savefig)  # backup the old save-function
 
 
@@ -532,6 +535,10 @@ def apply_styles(plot_function: Optional[PlotFunction] = None, *,
             plt.savefig = new_save_simple(png=False)
             _plot_function(*args, **kwargs)
 
+            if PREVIEW:
+                # don't create the styled plots
+                return
+
             errors = (OSError, FileNotFoundError, ThreeDPlotException,
                       FallBackException)
 
diff --git a/src/scientific_plots/utilities.py b/src/scientific_plots/utilities.py
index af8c645..d4ac461 100644
--- a/src/scientific_plots/utilities.py
+++ b/src/scientific_plots/utilities.py
@@ -262,7 +262,9 @@ def translate(string: str, reverse: bool = False) -> str:
         "absolute pressure": "Absolutdruck",
         "relative": "relativ",
         "absolute": "absolut",
-        "plot": "Graph"
+        "plot": "Graph",
+        "orifice": "Blende",
+        "Hagen–Poiseuille": "Hagen-Poiseuille"
     })
     if not reverse and r"\times" not in string:
         for key, value in _dict.items():
-- 
GitLab