diff --git a/yli/graphs.py b/yli/graphs.py index 99585c3..c20c927 100644 --- a/yli/graphs.py +++ b/yli/graphs.py @@ -1,5 +1,5 @@ # scipy-yli: Helpful SciPy utilities and recipes -# Copyright © 2022–2023 Lee Yingtong Li (RunasSudo) +# Copyright © 2022–2024 Lee Yingtong Li (RunasSudo) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -52,6 +52,9 @@ class HorizontalEffectPlot: self.text_right[0].append(EffectPlotText(header_y, measure_name, skip_width=True, ha='center', fontweight='medium')) self.text_right[2].append(EffectPlotText(header_y, '(95% CI)', skip_width=True, ha='center', fontweight='medium')) self.text_right[5].append(EffectPlotText(header_y, 'p', skip_width=True, ha='center', fontweight='medium', fontstyle='italic')) + + self.fig = None + self.ax = None def add_nobar(self, y, label, mean=None, ci0=None, ci1=None, pvalue=None): # Label @@ -117,7 +120,9 @@ class HorizontalEffectPlot: fig_height = 0.3 * max(d.y for d in self.data) + 0.2 - self.fig, self.ax = plt.subplots(figsize=(width, fig_height)) + if self.fig is None or self.ax is None: + self.fig, self.ax = plt.subplots(figsize=(width, fig_height)) + if xscale == 'log': self.ax.axvline(1, color='grey', linewidth=1) else: