rj678 / pycausalmatch

Causal Impact of an intervention integrated with control group selection
MIT License
9 stars 3 forks source link

Save Graph #5

Closed dariocorral closed 2 years ago

dariocorral commented 3 years ago

Hi,

First of all thanks for sharing this project. It's very useful

I know that it seems a stupid question but I don't know how can I save your plots like this one from your notebook example.

`results_only_cph'all_output_plots'

Thanks

rj678 commented 3 years ago

thanks for your definitely-not-stupid question @dariocorral , I expose the underlying Causal Impact object with the results, which is available at results_only_cph['causal_impact_object'] , and someone was kind enough to add a kwarg show to give access to the figure so it could be saved (see this PR: https://github.com/WillianFuks/tfcausalimpact/pull/13)

can you try this to save the figure:

import matplotlib.pyplot as plt
results_only_cph['causal_impact_object'].plot(show=False)
fig = plt.gcf()
fig.savefig("causal_results.png")

please let me know if this does not help