Skip to content

Add is_widget_backend() to the widget code path - #595

Open
MridulS wants to merge 1 commit into
scipp:mainfrom
MridulS:fix_widget_backend
Open

Add is_widget_backend() to the widget code path#595
MridulS wants to merge 1 commit into
scipp:mainfrom
MridulS:fix_widget_backend

Conversation

@MridulS

@MridulS MridulS commented Jul 30, 2026

Copy link
Copy Markdown
Member

This should fix #589

I think InteractiveFigure is a bit misleading? Shouldn't this be something like WidgetFigure, as InteractiveFigure subclasses ipywidgets.

@MridulS
MridulS requested a review from nvaytet July 30, 2026 09:26
@doronbehar

Copy link
Copy Markdown
Contributor

I tried this patch on NixOS with:

python -c 'import matplotlib.pyplot as plt; import scipp as sc; sc.arange("x", 5.0).plot(); plt.show()'

And it simply did nothing... I then tried:

python -c 'import matplotlib.pyplot as plt; import scipp as sc; print(sc.arange("x", 5.0).plot()); plt.show()'

Which printed:

<plopp.backends.matplotlib.figure.StaticFigure object at 0x78cce095af90>

Is this something I do wrong?

@nvaytet

nvaytet commented Jul 30, 2026

Copy link
Copy Markdown
Member

I think InteractiveFigure is a bit misleading? Shouldn't this be something like WidgetFigure, as InteractiveFigure subclasses ipywidgets.

I agree. By the same token, maybe StaticFigure is also a bad name? Because if you use the qt backend, it makes a StaticFigure but the figure isn't static at all. Should we call them WidgetFigure and ... something better? MplFigure?

@nvaytet

nvaytet commented Jul 30, 2026

Copy link
Copy Markdown
Member

Is this something I do wrong?

I usually did it via ipython, and using the fig.show() method instead of the plt.show(). Example in a ipython console:

import plopp as pp

f = pp.data.data1d().plot()
f.show()

works for me.

For the on-liner python -c, I think it makes the figure but closes it instantly so that I don't see it. Waiting for input at the end shows the figure:

python -c 'import scipp as sc; f = sc.arange("x", 5.0).plot(); f.show(); input()'

I am currently not sure why the matplotlib plt.show() does not work.

@doronbehar

Copy link
Copy Markdown
Contributor

Example in a ipython console:

Doesn't work for me - I did created a Python file this time:

import scipp as sc
f = sc.arange("x", 5.0).plot()
f.show()

For the on-liner python -c, I think it makes the figure but closes it instantly so that I don't see it. Waiting for input at the end shows the figure:

Indeed! But this is very peculiar...

I am currently not sure why the matplotlib plt.show() does not work.

Yea for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't plot anything without ipywidgets?

3 participants