Store Figure and Axes instances in HorizontalEffectPlot

This commit is contained in:
RunasSudo 2024-01-25 23:21:17 +11:00
parent b837ecc3a3
commit 553448e59a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 7 additions and 2 deletions

View File

@ -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: