RJT1990 / pyflux

Open source time series library for Python
BSD 3-Clause "New" or "Revised" License
2.11k stars 240 forks source link

Allow multiple plot_predict graphs in one matplotlib figure #73

Open izzy opened 7 years ago

izzy commented 7 years ago

I'd like to plot multiple prediction graphs in the same figure. Currently if I call e.g. DAR.plot_predict() multiple times, it'll just open multiple figures.

To make that work for now, I've just patched the plot_predict definition to take a plt argument and disabled plt.show() when it's set in kwargs, but that seems not very elegant to do and I have to call plt.show() somewhere else.

RJT1990 commented 7 years ago

Yes, I've thought about this myself - can you think of any good data science libraries with plotting capablities that do this in a more elegant way? I like the ease with which the current functions in the library allow you to plot properties of the model, but yes, it doesn't really support custom figures (grids) that would be nice to have ideally.

izzy commented 7 years ago

I can't of any better lib than matplot, but maybe there's a better, more elegant pattern to use it instead of importing it inside of the class method?

tacaswell commented 7 years ago

The easiest way to support this is to take an optional ax kwarg to the plotting methods which determine which Axes to plot to. If ax is None fall back to fig, ax = plt.subplots().