sagemath / sagetex

Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
https://ctan.org/pkg/sagetex
Other
58 stars 22 forks source link

`\sageplot` and suggest for using a fixed matplotlib render backend #29

Open amurzeau opened 5 years ago

amurzeau commented 5 years ago

Hi,

While analyzing a sagetex autopkgtest issue in Debian when the sagemath package removed its dependency to python-tk, I found that sagetex required python-tk to generate graph with \sageplot.

Actually, I found in matplotlib usage FAQ that matplotlib can use many different backends. There are rendering backends and interactive backends. Cairo is a rendering backend for example, and TK is an interactive one. The default used backend is chosen according to different things (configuration file, environment variable, python function call).

Actually, sagetex is using the default backend which is TkAgg and so require python-tk when doing \sageplot.

I don't think sagetex actually require an interactive backend, but just something that can generate a pdf, eps of image file is enough. So a rendering backend could be enough for sagetex. Also, sagetex should not depend on user configuration of matplotlib as it seems the case (I've not checked myself but just read matplotlib docs, so it might be different)

So I suggest that sagetex:

According to matplotlib usage FAQ, cairo is the only one to support multiple formats including eps, pdf and png.

Here is the Debian bug for reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=921120