question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to achieve interactive plot

See original GitHub issue

Environment data

  • VS Code version: 1.67.2 (current)
  • Jupyter Extension version (available under the Extensions sidebar): Jupyter v2022.4.1021342353
  • Python Extension version (available under the Extensions sidebar): Python v2022.6.3
  • OS (Windows | Mac | Linux distro) and version: macOS 12.4 (Monterey) (Current)
  • Python and/or Anaconda version: 3.10.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): python -m venv .venv
  • Jupyter server running: Local

Expected behaviour

Running example from https://mplcursors.readthedocs.io/en/stable/ in a fresh .ipynb

Expecting to be able to click on the plot that is output, and for it to “interactively” respond to cursor location.

Actual behaviour

It doesn’t.

Steps to reproduce:

Just create a fresh .ipynb and stick the first code example from the above link in a cell:

# https://mplcursors.readthedocs.io/en/stable/
import matplotlib.pyplot as plt
import numpy as np
import mplcursors

data = np.outer(range(10), range(1, 5))

fig, ax = plt.subplots()
lines = ax.plot(data)
ax.set_title("Click somewhere on a line.\nRight-click to deselect.\n"
             "Annotations can be dragged.")

mplcursors.cursor(lines)  # or just mplcursors.cursor()

plt.show()

Now this is likely an issue with backends. Prefixing %matplotlib outputs no plot, but instead:

Using matplotlib backend: <object object at 0x112c49f20>

Please could we have instruction how to achieve interactive-plots, or an explanation of why we can’t. If cannot, is it in the pipeline? What is blocking it?

I can’t find any clear definitive documentation on backends, and how they apply in VSCode’s Notebook editor.

I would love to be able to transition 100% from Jupyter Notebooks (operating out of web browser).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jackthepanishercommented, Jun 2, 2022

I think you will need %matplotlib widget to enable support for mpl widgets. This might require to install the ipympl package as well. I haven’t looked much into the details and also haven’t found much further information on the mplcursors site but JupyterLab seems to require the same to display the interactive cursors.

0reactions
rchiodocommented, Jun 6, 2022

We don’t control the colors for the matplotlib widget. That’s entirely in matplotlib’s code. I believe the docs for the ipympl backend (what it uses when you specify %matplotlib widget) are here:

https://matplotlib.org/ipympl/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Matplotlib interactive mode won't work, no matter what I do
On the other hand, the figure that appears, is clear, but not interactive. I cannot zoom or pan. It crashes when I try....
Read more >
[Matplotlib-users] Can't get interactive plots working on OSX ...
The short answer: something has to run the GUI event loop while the prompt is waiting for user input. This is typically called...
Read more >
How to make Plot to be an Interactive Plot in Python Pandas ...
The next tip I want to cover is how to make your plots that pandas provides to be an interactive plot. There is...
Read more >
Interactive Plots — FiftyOne 0.18.0 documentation - Voxel51
Interactive plots are currently only supported in Jupyter notebooks. In the meantime, you can still use FiftyOne's plotting features in other environments, but ......
Read more >
Frequently Asked Questions - LocusZoom
A plot may not generate if the SNP name or gene name cannot be found. Please double-check the gene name exists in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found