0

I am using Jupyter Lab 2.0, matplotlib 3.2.0 and Python 3.8.0

So, I found out you can get interactive plots in Jupyter Lab, and embarked on the journey to make this happen for myself. Along the way, here are the things I tried:

  1. Ensured nodejs is installed
  2. Installed the Jupyter Lab extension manager
  3. Installed ipympl
  4. Installed jupyter-matplotlib
  5. Re-build JupyterLab
  6. Restart JupyterLab (several times)

Next, in my code I tried all of the following common recommendations (alone and in various combinations):

matplotlib.use("nbragg")
%matplotlib ipympl
%matplotlib widget
%matplotlib inline

At best, some of these cause all of my rcParams defaults to be overridden, and show tiny graphs with no interactivity. At worst, my graphs don't show at all, except for sometimes displaying some random text below the code.

I have tried all of the suggestions from the following SO answers, GitHub and matplotlib docs:

Sample of my working code:

train_df = pd.read_csv('data/train.csv', index_col='PassengerId')
test_df = pd.read_csv('data/test.csv', index_col='PassengerId')
survival = train_df.pop('Survived')
df = pd.concat([train_df, test_df])

# extract last names and titles:
df['Title'] = df.Name.str.extract(r'([A-Za-z]+)\.')

# extract last name: 
df['LName'] = df.Name.str.extract(r'([A-Za-z]+),')

# Plot histogram of parsed titles:
sns.countplot(df.Title).set_title("Histogram of Passenger Titles")
plt.show()

Note that I have tried this with and without plt.show().

rocksNwaves
  • 5,331
  • 4
  • 38
  • 77
  • could you share some of your code? – kpie Mar 19 '20 at 18:02
  • @kpie done. Added a small snippet of a graph that previously showed perfectly well, albeit without interactivity. – rocksNwaves Mar 19 '20 at 18:14
  • Have you looked at [this ipympl issue](https://github.com/matplotlib/ipympl/issues/201#issue-580651502)? – Wayne Mar 19 '20 at 18:46
  • @Wayne no I hadn't, but just read through it. A lot of that is technically over my head. I'm still at the point where if it's not plug and play, I have a hard time. If I am understanding the final resolution it comes down to literally uninstalling everything python related and starting from scratch. I think I'll just stick with my non-interactive plots if that is the case. – rocksNwaves Mar 19 '20 at 18:57
  • The binder demo now works again if you can use it remotely? That uses JupyterLab 1.2.6. I'm about to test if it fixes it for version 2.0, now. – Wayne Mar 19 '20 at 19:37
  • 1
    ipympl remote served via MyBInder works in 2.0.1 as well. Confirmed. Go [here](https://github.com/fomightez/ipympl). Note for JL 2.0 involves (or at least works with it like this) making `jupyter labextension install` in postBuild one line, see [here](https://github.com/matplotlib/ipympl/commit/236f00008892139cfedb1a47fdb61f0e87c4eef7), while that breaks JupyterLab 1.2.6 on Binder. Needs to be two lines. Odd. – Wayne Mar 19 '20 at 21:23
  • @Wayne thank you for taking the time to dig into it for me. It'll take me some time to dig into what you've got there It'll be good practice for me to learn what's going on behind the curtain, and hopefully give me some cool interactive plots. – rocksNwaves Mar 19 '20 at 21:34
  • Use the `launch binder` button, if I didn’t say that. – Wayne Mar 20 '20 at 02:17

0 Answers0