Store Figure and Axes instances in HorizontalEffectPlot
This commit is contained in:
parent
b837ecc3a3
commit
553448e59a
@ -1,5 +1,5 @@
|
|||||||
# scipy-yli: Helpful SciPy utilities and recipes
|
# 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
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -53,6 +53,9 @@ class HorizontalEffectPlot:
|
|||||||
self.text_right[2].append(EffectPlotText(header_y, '(95% CI)', 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.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):
|
def add_nobar(self, y, label, mean=None, ci0=None, ci1=None, pvalue=None):
|
||||||
# Label
|
# Label
|
||||||
self.text_left[0].append(EffectPlotText(y, label, ha='right'))
|
self.text_left[0].append(EffectPlotText(y, label, ha='right'))
|
||||||
@ -117,7 +120,9 @@ class HorizontalEffectPlot:
|
|||||||
|
|
||||||
fig_height = 0.3 * max(d.y for d in self.data) + 0.2
|
fig_height = 0.3 * max(d.y for d in self.data) + 0.2
|
||||||
|
|
||||||
|
if self.fig is None or self.ax is None:
|
||||||
self.fig, self.ax = plt.subplots(figsize=(width, fig_height))
|
self.fig, self.ax = plt.subplots(figsize=(width, fig_height))
|
||||||
|
|
||||||
if xscale == 'log':
|
if xscale == 'log':
|
||||||
self.ax.axvline(1, color='grey', linewidth=1)
|
self.ax.axvline(1, color='grey', linewidth=1)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user