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

displaying plots via Jupyter as SVG doesn't work #35972

Open
2 tasks done
williamstein opened this issue Jul 20, 2023 · 0 comments
Open
2 tasks done

displaying plots via Jupyter as SVG doesn't work #35972

williamstein opened this issue Jul 20, 2023 · 0 comments

Comments

@williamstein
Copy link
Contributor

williamstein commented Jul 20, 2023

Steps To Reproduce

  1. Using the SageMath (10.0) Jupyter kernel, try to switch the output from the default of png to use svg instead, using the standard suggested commands.
  2. All attempts are ignored or fail.
  3. The same thing works fine with matplotlib and the Python directly.

Here's the code in any Jupyter notebook to try this:

%matplotlib inline
import matplotlib_inline
matplotlib_inline.backend_inline.set_matplotlib_formats('svg')

then

plot(sin,0,2)

and open the image (e.g., in another tab) to see it is a PNG.

You can also try the older, and evidently now deprecated, but much easier to input

%config InlineBackend.figure_formats = 'svg'

and it also doesn't work.

I've tested this in various notebook environments, e.g., Jupyter classic and CoCalc. Of course the problem is more on the side of the kernel, not the frontend.

Expected Behavior

Plots to be displayed using SVG instead of PNG.

Actual Behavior

All attempts are ignored and PNG is output.

Additional Information

This is a page discussing this sort of behavior in Python:

https://stackoverflow.com/questions/36622237/jupyter-notebook-inline-plots-as-svg

That page is pretty ridiculous though as each answer becomes deprecated or broken from one year to the next. I wish people cared more about stability for users, and I can see how this has been very frustrating to support or get right in sage over the years.

Incidentally the motivation is that SVG looks massively better if you have a modern high resolution display.

See also https://cocalc.com/hsy/ubuntu-22.04-testing/jupyter-plot-png-svg for how things work in Python + Matplotlib, which is how people will expect things to work in Sage.

Environment

  • OS : Ubuntu 22.04
  • Sage Version : 10.0

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants