Can I use the IPython magic function %matplotlib qt with seaborn.objects?

180 Views Asked by At

Typically if I want to make an interactive plot, I use %matplotlib qt, such that I can explore, zoom, add to the figure etc. I wanted to make an area plot, and with the release of seaborn objects, this is easy. Only, it always plots "inline" in my console (spyder), which I find really user-unfriendly as compared with the interactive plotting I normally do (with the normal seaborn plots which are built on matplotlib, there is no problem). Is there anyone who knows a solution for this?

fig, ax = plt.subplots(nrows = 1, ncols = 1, figsize=(15,8))
p = so.Plot(sumstat, "date", "std")
p.add(so.Area())
1

There are 1 best solutions below

0
mwaskom On

To compile the Plot using the axes that you have created, you want Plot.on:

fig, ax = plt.subplots(nrows = 1, ncols = 1, figsize=(15,8))
(
    so.Plot(sumstat, "date", "std")
    .add(so.Area())
    .on(ax)
)

Or you can keep the entire specification within the objects interface but hook into pyplot for the display using Plot.show:

(
    so.Plot(sumstat, "date", "std")
    .add(so.Area())
    .layout(size=(15, 8))
    .show()
)