Skip to content

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

Merged
nvaytet merged 2 commits into
scipp:mainfrom
MridulS:fix_widget_backend
Jul 31, 2026
Merged

Add is_widget_backend() to the widget code path#595
nvaytet merged 2 commits 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.

@nvaytet

nvaytet commented Jul 31, 2026

Copy link
Copy Markdown
Member

@MridulS do you want to proceed with the renaming or should I do it?
Would be nice to get this merged soon :-)

@MridulS

MridulS commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@MridulS do you want to proceed with the renaming or should I do it?

Didn't want to add the change to this pr, but feel free to push here and merge :)

@nvaytet
nvaytet merged commit da77c44 into scipp:main Jul 31, 2026
5 checks passed
@doronbehar

Copy link
Copy Markdown
Contributor

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

Yea for me too.

Are you going to at least document this behavior somewhere? It could be hard to diagnose for future users like me...

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