Search code examples
pycharmpymc3arviz

PyMC3 plots.traceplot in PyCharm


Is there something extra I need to do to show my PyMC3 plots.traceplot results in PyCharm? I just discovered that I need a print() statement around pm.summary(). so I'm wondering if there is another function for the plots. Thank You!


Solution

  • PyMC3 uses ArviZ for plotting (as well as for statistics and summary such as summary) which at the same time, relies on either matplotlib of Bokeh. To be able to call several plotting commands and customize the figures, both libraries require to call a command at the end to finish figure creation and show the generated plot. In matplotlib's case, it's matplotlib.pyplot.show() and in Bokeh's case it's bokeh.plotting.show(plot).

    When using ArviZ in an interactive manner (and therefore barely customizing ArviZ generated plots), ArviZ can be configured to automatically show all generated plots by doing:

    import arviz as az
    az.rcParams["plot.matplotlib.show"] = True  # bokeh plots are automatically shown by default
    

    This will make pm.traceplot automatically show the plot straight away. If this is a too general setting, there is also the option of using pm.traceplot(..., show=True) on a per plot basis.