Ask Your Question

leogama's profile - activity

2024-02-04 23:02:00 +0200 received badge  Famous Question (source)
2022-01-22 03:50:09 +0200 received badge  Notable Question (source)
2022-01-09 07:45:58 +0200 received badge  Popular Question (source)
2021-06-08 01:09:17 +0200 received badge  Nice Answer (source)
2020-10-11 13:43:22 +0200 received badge  Self-Learner (source)
2020-10-11 13:43:22 +0200 received badge  Teacher (source)
2020-10-11 10:19:31 +0200 received badge  Nice Question (source)
2020-10-11 03:41:21 +0200 received badge  Editor (source)
2020-10-11 03:39:51 +0200 answered a question How to set the matplotlib backend used by plot()

Thank you, @Sébastien. From your comment and documentation references, it seems clear that:

  1. The %matplotlib is an IPython-only mechanism; and
  2. SageMath's command-line IPython backend currently doesn't support matplolib GUI.

The second conclusion comes from the reported by get_display_manager().supported_output():

frozenset({..., <class 'sage.repl.rich_output.output_graphics.OutputImageDvi'>, <class 'sage.repl.rich_output.output_graphics.OutputImageGif'>, <class 'sage.repl.rich_output.output_graphics.OutputImagePdf'>, <class 'sage.repl.rich_output.output_graphics.OutputImagePng'>, ...})

The only other output types for 2D images defined in Sage's library are for JPEG and SVG files. Not a single mention to matplotlib GUI backends. It would be necessary to define a new output type class in order to use it natively in Sage, although it doesn't seem too hard to implement.

For now, I'll live with the Graphics2d to matplotlib object conversion!

2020-10-09 02:57:08 +0200 received badge  Student (source)
2020-10-09 02:55:45 +0200 asked a question How to set the matplotlib backend used by plot()

SageMath uses matplotlib as its graphics engine and the module itself can work with many backends. But how can I set a GUI matplotlib backend to be used by the plot() function and its friends, at least in the command-line interface? And is there a way to set a default backend?

In my setup, plot() doesn't respect the backend set by the %matplotlib magic, but matplotlib.pyplot.plot() does. Even worse, the default backend creates a PNG image file and opens it in the system's viewer.

I'm on macOS 10.13 "High Sierra" running SageMath 9.1, the binary app version.