From 00aebc7f6f8ca167e3246bc4c8de43969c5fd23c Mon Sep 17 00:00:00 2001 From: Felix Fischer <f.fischer@ifas.rwth-aachen.de> Date: Tue, 18 Mar 2025 15:44:24 +0100 Subject: [PATCH] Add the settings to use the inner limits on the y-axis --- src/scientific_plots/__init__.py | 2 +- src/scientific_plots/default_plots.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/scientific_plots/__init__.py b/src/scientific_plots/__init__.py index 530b04e..f5f8f0e 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.8" +__version__ = "1.8.9" diff --git a/src/scientific_plots/default_plots.py b/src/scientific_plots/default_plots.py index 97fbc82..61a6f77 100644 --- a/src/scientific_plots/default_plots.py +++ b/src/scientific_plots/default_plots.py @@ -366,7 +366,8 @@ def two_plots(x1: In, y1: In, label1: str, single_log: bool = False, single_log_y: bool = False, xlim: Optional[Tuple[float, float]] = None, - ylim: Optional[Tuple[float, float]] = None) -> None: + ylim: Optional[Tuple[float, float]] = None, + inner_y: bool = False) -> None: """Create a simple 1D plot with two different graphs inside of a single plot and a single y-axis. @@ -374,6 +375,7 @@ def two_plots(x1: In, y1: In, label1: str, cycle -- skip this many colours in the colour-wheel before plotting color -- use these indeces in the colour-wheel when creating a plot outer -- use the outer limits on the x-axis rather than the inner limit + inner_y -- Use the tighter definition for the limits on the y-axis """ x1, y1 = fix_inputs(x1, y1) # type: ignore x2, y2 = fix_inputs(x2, y2) # type: ignore @@ -431,9 +433,14 @@ def two_plots(x1: In, y1: In, label1: str, x2, y2, xlim=xlim, logscale=(logscale or single_log_y)) - plt.ylim( - min(ylim1[0], ylim2[0]), - max(ylim1[1], ylim1[1])) + if inner_y: + plt.ylim( + max(ylim1[0], ylim2[0]), + min(ylim1[1], ylim2[1])) + else: + plt.ylim( + min(ylim1[0], ylim2[0]), + max(ylim1[1], ylim2[1])) else: plt.ylim(*ylim) -- GitLab