Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas plot display a plot only for the first cell executed (jupyterlab4) #15233

Open
matrs opened this issue Oct 6, 2023 · 6 comments
Open
Labels

Comments

@matrs
Copy link

matrs commented Oct 6, 2023

Description

When using pandas with the default backend (matplotlib), the plot is displayed only for the first cell that plots something. Later calls to the same cell or any other cell with the pandas plot functionality doesn't display the plot, only the name of the object, e.g <AxesSubplot:> . This behavior can be fixed when calling once, in any cell, %matplotlib inline. I never found this behavior in jupyterlab 2.x or 3.x and i haven't called %matplotlib inline in years.

Reproduce

Execute this code in a clean notebook

num_rows = 1000
df = pd.DataFrame({"random_float": np.random.rand(num_rows)})
df.boxplot()

Executing the cell again doesn't display the plot. New cells with the same or any other code using the plot functionality doesn't display the plots.

Im in arch linux with:

  • jupyterlab 4.0.6
  • matplotlib 3.5.3, 3.8.0
  • pandas 1.5.3
  • python 3.10.9
  • firefox 117.0.1
@matrs matrs added the bug label Oct 6, 2023
@welcome
Copy link

welcome bot commented Oct 6, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Oct 6, 2023
@matrs matrs changed the title pandas plots display a plot only for the first cell executed in jupyterlab4 pandas plot display a plot only for the first cell executed (jupyterlab4) Oct 6, 2023
@krassowski
Copy link
Member

It works for me with matplotlib 3.6.2 and pandas 2.0.3. You are using an older version of matplotilb (and pandas). Could you try upgrading matplotilb to the latest version?

@matrs
Copy link
Author

matrs commented Oct 7, 2023

I updated my matplotlib version to the latest (3.8). With pandas is different, I haven't updated it because I have code that fails with > 2 and haven't had time to check it (also, until now, every new release fixes plenty of regressions).

I still have the same problem, I'm attaching a gif:
jlab_plotbug

@krassowski
Copy link
Member

Thank you! After running the cells for the second time, is there any error in the web JS console? Could you paste these if any?

@matrs
Copy link
Author

matrs commented Oct 21, 2023

@krassowski , there is no errors in the console (I have all the types of output checked). There is no output difference between the first and following cell executions.

@krassowski
Copy link
Member

Does it also happen with visualisations which are not matplotlib-based, or is it specific to matplotlib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants