title: PyCharm Not Always Plotting In New Figures
body: <p>I have the latest version of PyCharm installed (2020.2.2 Pro). I have PyCharm configured to plot into the SciView.</p>
  <p>When I run the following code 5 times it generates a new plot only twice. All other times it overwrites the previous figure.</p>
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  plt.figure()
  plt.plot(np.sin(np.linspace(0,5,100)))
  plt.show()
  </code></pre>
  <p>This behavior is pretty obnoxious when one wants to compare the results of multiple plots.</p>
  <p>My PyCharm is also configured to start a new python instance on every run of the file. I also see the same behavior if I omit the <code>plt.figure()</code> line.</p>
  <p>Additionally, the new plots don't appear in any repeatable way. Like I run this code 3 times I only get one plot from the first run, but then on the 4th run I get a second plot.</p>
  <p>If I disable plotting in SciView through <code>Settings&gt;Python Scientific&gt;Show plots in tool window</code>. I generate a new plot every time I run the code.</p>
  <p>The plot which is replaced when I rerun the code is randomly selected as well. If I have say 4 plots and one of them gets replaced it is usually the one with the bottom thumbnail, but sometimes another random one in the list is replaced instead.</p>
  <p>If I set <code>Settings&gt;Build, Execution, Deployment&gt;Console&gt;Use existing console for &quot;Run with Python Console&quot;</code> I get a new figure each time. This is fine, except I require a fresh console for every run as I'm often modifying libraries that are imported by the code that generates the plots. If I don't get a fresh console the the imports are ignored and the existing version of the library stays in the interpreters memory. I suppose I can work around this by setting <code>%autoreload</code> in iPython, but it's a bit of a hack...</p>
  <p>If you're having this issue try setting <code>Use existing console for &quot;Run with Python Console&quot;</code> and putting the following somewhere in the python file you're running</p>
  <pre><code>from IPython import get_ipython
  ipython = get_ipython()
  if ipython is not None:
      ipython.magic(&quot;%load_ext autoreload&quot;)
      ipython.magic(&quot;%autoreload&quot;)
  </code></pre>