Repository: mne-tools/mne-python

Issue:
Raw.plot() issue
I found something maybe a bug.
Now I used the master branch in GitHub.  I use Pycharm and terminal to run codes. One of my examples uses **raw.plot()** to plot raw data.  While I ran codes in Pycharm's console, **raw.plot()** went well, a figure showed up. While I ran .py in terminal like **python test.py**, no figure showed up. And if I type **python** in the terminal and type the codes in this way, also no figures showed up. But if I used the stable mne, everything was OK.


Discussion:
Can you provide a minimal example (ideally using a sample dataset shipped with MNE) that demonstrates the issue?
Now I use https://mne.tools/stable/auto_tutorials/raw/plot_40_visualize_raw.html#sphx-glr-auto-tutorials-raw-plot-40-visualize-raw-py to plot raw data run by the terminal in win10. When I ran raw.plot(), nothing showed up.
my mne version is 0.22.dev0

> While I ran .py in terminal like **python test.py**, no figure showed up.

Can you try running in the terminal with

```
python -i test.py
```

> > While I ran .py in terminal like **python test.py**, no figure showed up.
> 
> Can you try running in the terminal with
> 
> ```
> python -i test.py
> ```

I did that, it was the same. no figure.
import os
import mne

sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.crop(tmax=60).load_data()

raw.plot()
In the stable version, it went well. 
The interesting thing is, if I run the codes in Python Conole in pycharm, the figure will show up.
@drammock You think this could be related somehow to the new figure class?
Can reproduce on macOS with `master`.
@BarryLiu-97 
I worked around this problem by adding
```python
import matplotlib.pyplot as plt
plt.show()
```
at the end of your script
> @BarryLiu-97
> I worked around this problem by adding
> 
> ```python
> import matplotlib.pyplot as plt
> plt.show()
> ```
> 
> at the end of your script

Yeah, that's right. Me too. 
> > @BarryLiu-97
> > I worked around this problem by adding
> > ```python
> > import matplotlib.pyplot as plt
> > plt.show()
> > ```
> > 
> > 
> > at the end of your script
> 
It reminds me that Pycharm console is like jupyter notebook, don't need plt.show and the figure still shows up.
> > > @BarryLiu-97
> > > I worked around this problem by adding
> > > ```python
> > > import matplotlib.pyplot as plt
> > > plt.show()
> > > ```
> > > 
> > > 
> > > at the end of your script
> 
> It reminds me that Pycharm console is like jupyter notebook, don't need plt.show and the figure still shows up.

Seems that I still have a lot to learn. I didn't connect my experience to this issue.
> Seems that I still have a lot to learn. I didn't connect my experience to this issue.

That may be true, but you actually discovered a bug in MNE, so it's great you reported it! It should've worked the way you tried to do it. We'll see how we can fix this.
> > Seems that I still have a lot to learn. I didn't connect my experience to this issue.
> 
> That may be true, but you actually discovered a bug in MNE, so it's great you reported it! It should've worked the way you tried to do it. We'll see how we can fix this.

All right, Thank you! Looking forward to it.

Resolving patch:
diff --git a/mne/viz/_figure.py b/mne/viz/_figure.py
--- a/mne/viz/_figure.py
+++ b/mne/viz/_figure.py
@@ -695,6 +695,7 @@ def _create_ch_location_fig(self, idx):
         # fig.lasso.alpha_other = 0.3
         # fig.lasso.linewidth_selected = 3
         # fig.lasso.style_sensors(inds)
+        # plt_show(fig=fig)
 
     # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
     # HELP DIALOG
@@ -728,6 +729,7 @@ def _create_help_fig(self):
         kwargs = dict(va='top', linespacing=1.5, usetex=False)
         ax.text(0.42, 1, keys, ma='right', ha='right', **kwargs)
         ax.text(0.42, 1, vals, ma='left', ha='left', **kwargs)
+        plt_show(fig=fig)
 
     def _toggle_help_fig(self, event):
         """Show/hide the help dialog window."""
@@ -1299,7 +1301,7 @@ def _create_proj_fig(self):
         fig.mne.proj_checkboxes = checkboxes
         # show figure
         self.mne.fig_proj.canvas.draw()
-        plt_show(fig=self.mne.fig_proj, warn=False)
+        plt_show(fig=fig)
 
     def _toggle_proj_fig(self, event=None):
         """Show/hide the projectors dialog window."""
diff --git a/mne/viz/raw.py b/mne/viz/raw.py
--- a/mne/viz/raw.py
+++ b/mne/viz/raw.py
@@ -405,6 +405,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20,
     fig.canvas.flush_events()
     fig.mne.bg = fig.canvas.copy_from_bbox(fig.bbox)
 
+    plt_show(show, block=block)
     return fig
 
 


Test patch: