Skip to content

Commit

Permalink
option to plot using circles rather than bars
Browse files Browse the repository at this point in the history
  • Loading branch information
tbhallett committed Aug 20, 2024
1 parent c81918a commit 882ba04
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def find_difference_relative_to_comparison(_ser: pd.Series,
.drop(columns=([comparison] if drop_comparison else [])) \
.stack()

def do_bar_plot_with_ci(_df, annotations=None, xticklabels_horizontal_and_wrapped=False):
def do_bar_plot_with_ci(_df, annotations=None, xticklabels_horizontal_and_wrapped=False, circles=False):
"""Make a vertical bar plot for each row of _df, using the columns to identify the height of the bar and the
extent of the error bar."""
yerr = np.array([
Expand All @@ -102,11 +102,14 @@ def do_bar_plot_with_ci(_df, annotations=None, xticklabels_horizontal_and_wrappe
xticks.keys(),
_df['mean'].values,
yerr=yerr,
alpha=0.5,
alpha=0.5 if not circles else 0.0,
ecolor='black',
capsize=10,
label=xticks.values()
)
if circles:
ax.plot(xticks.keys(), _df['mean'].values, marker='o', color='black', markersize=10, linestyle='')

if annotations:
for xpos, ypos, text in zip(xticks.keys(), _df['upper'].values, annotations):
ax.text(xpos, ypos*1.05, text, horizontalalignment='center')
Expand Down Expand Up @@ -316,6 +319,7 @@ def rename_scenarios_in_index(ser: pd.Series) -> pd.Series:
for _, row in pc_dalys_averted.clip(lower=0.0).iterrows()
],
xticklabels_horizontal_and_wrapped=True,
circles=True,
)
ax.set_title(name_of_plot)
ax.set_ylim(0, 16)
Expand Down

0 comments on commit 882ba04

Please sign in to comment.