I want to draw some other results on my plot_trace pitures, but I cannot find methods like “holdon” or plt.plot(hold=True), so do you have useful methods to hold on plot_trace pictures?
arviz plot should return a matplotlib axes object that you can modify.
Moreover, if I remember correctly, hold was deprecated and removed in matplotlib 3.0 which is the minimum required by ArviZ, so trying to use it will probably end up raising an invalid argument error.
Remember to set
show=False if called from python script. (And then manually call
plt.show() if needed)
Thank you! So if I use plt.plot() after az.plot_trace, will the lines directly add on the returned arviz picture instead of plotting on a new figure?
It will plot over the last subplot - e.g., for a plot_trace of a single RV, it will plot on the right side subplot. If you want to plot over a different subplot you have to select a different axis. Note that the left side subplots use quite a different scale to the right side.
pm.traceplot(trace) axes = plt.gcf().get_axes() ax = axes # select the first subplot geom = ax.get_geometry() # check we've got the correct one print(geom) # output: (1, 2, 1) - first of 2 subplots plt.sca(ax) # set current subplot plt.plot(data)
Thank you! I get it!