Open Noctiphobia opened 6 years ago
I do not use PyCharm, so I have no way of testing this, but it seems like SciView interferes with the cleaning up of matplotlib figures. IPython has set_matplotlib_close that closes all figures after each cell is run.
So, if you do this in IPython
import plotnine as p9
import pandas as pd
from IPython.core.display import set_matplotlib_close
set_matplotlib_close(False)
you should get unwanted plots showing up in there too!
Does someone found a solution for this problem?
I have this issue too and it's making plotnine unusable because every time I create a new plot, it also re-creates several other plots. There must be some way to reset plotnine's state to prevent this?
I have also created an issue in PyCharm in case the bug is actually there: https://youtrack.jetbrains.com/issue/PY-42390
According to https://github.com/has2k1/plotnine/issues/397#issuecomment-627346430, SciView implements its own backend "interAgg" and that may be to cause of this.
When creating any plot with PlotNine and running it through IPython (6.2.1, Python 3.6.5) connected to PyCharm (2018.1.3 running on Linux 4.9.98-1-MANJARO #1 SMP PREEMPT Wed May 2 18:41:44 UTC 2018 x86_64 GNU/Linux) with SciView, more plots are drawn than expected. In particular, the last plot drawn with PlotNine is then drawn with every subsequent IPython call. For example after running the following code, 3 plots are drawn on SciView:
The first plot appears once, and the second appears twice (once due to print, and once due to the weird behavior I am describing). For every additional (unrelated) thing I do in IPython after calling the code above, I get another copy of the plot. For example:
If I draw a plot using IPython's implicit printing (not assigning the plot to any variable), as far as I know, there is no way to delete it, so the plot will keep appearing until I reset IPython.
Just to clarify, this does happen only when using PyCharm's SciView. Running this through a separate IPython instance (not connected to Pycharm) works perfectly fine.