3D sageplot static PNG quality (missing labels, etc.) — known workaround?

59 views
Skip to first unread message

Juan Carlos Bustamante

unread,
Sep 5, 2026, 1:48:18 PMSep 5
to PreTeXt support
Hi all,

I'm using <sageplot variant="3d"> for a 3D plot. The interactive HTML/three.js output looks great — text labels (text3d) included. But the static PNG used for the PDF/LaTeX version is noticeably worse overall, not just missing the text labels: the same Graphics3d object renders in a visibly lower-quality way for print than what I can get elsewhere.

A correctly-labeled, good-looking static image of the same plot is trivial to get outside this pipeline: e.g. a screenshot of the same Graphics3d object shown in a Jupyter notebook, where everything renders fine. So the "author supplies a static substitute" workflow is exactly the right one here — <sageplot> just has no attribute or child to receive it. (<interactive> already has this, via @preview or a <static> child — it's really just <sageplot> that's missing the equivalent.)

Is this a known limitation, and is there a workaround to get a good static image for print while keeping the interactive version for HTML? Or is something like @preview/<static> planned for <sageplot> too?

Thanks!

JC

Rob Beezer

unread,
Sep 5, 2026, 6:20:56 PMSep 5
to pretext...@googlegroups.com
Dear JC,

Our 3D plots from Sage have never been very good, and likely the code has not
been touched in years. So maybe we need to use better Sage code. Encouraging
authors to do extra work (manual screenshots) and override our automatic
production does not sound like the first solution to try.

Can we do something better (different Sage code) to get a better PNG (or other
format) image? Have you experimented within Sage itself?

I guess at worst, we might do the screenshots ourselves (i.e. automatically with
our existing tools)?

Rob
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-support/
> ef4649e2-39ac-4d63-bae9-e0329f1d9187n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/ef4649e2-39ac-4d63-bae9-
> e0329f1d9187n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Juan Carlos Bustamante

unread,
Sep 6, 2026, 11:07:23 AMSep 6
to pretext...@googlegroups.com
Dear Bob,

Yes, the problem comes from the fact that sage uses tachyon to save the 3d figures (I think). In any case, when i do my figure in a jupyter notebook and use Fig.save(...) I get the poor image pretext uses to build the pdf. Since the figures obtained as a preview for  an "interactive" pointing to the sage one cell-server are quite good, I would say that this is the right mechanism. So is this a feature request? In the meanwhile, is there a workaround?

JC 

To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDAxRC5PdHRjODk.1788646853%40pnsh.

Mitch Keller

unread,
Sep 8, 2026, 4:06:15 PMSep 8
to pretext...@googlegroups.com
Hi JC,

You can use an interactive with @platform=“sage” containing a slate with @surface=“sage”. That will get you the automated screenshots. For example, Figure 11.8.9 in ACM is generated by xi:include of this file in this source file

I didn’t actually know that one could use a sageplot with code for a 3D image inside it, so this is how we’ve done all of ours.

Mitch

Juan Carlos Bustamante

unread,
Sep 8, 2026, 9:09:41 PMSep 8
to pretext...@googlegroups.com

HI Mitch,

Yes, I know I can do that. As I point ou, the figures obtained this way are fine, but in the .pdf version one gets those QR codes, this is why I prefer to avoir interactives. Is there a way to avoir the QR code? They are too big, I simply do not want them on the .pdf version of what I am writing.

Perhaps I am wrong, but I tend to think that relying on my local SAGE is kind of better. Any advice on this?


JC

Mitch Keller

unread,
Sep 9, 2026, 10:14:26 AMSep 9
to pretext...@googlegroups.com
Hi JC,

For ACM, we use a mixture of just 3D plots and more elaborate Sage interacts, so standardizing has been mostly good for us. However, we do run into situations where the Javascript in the page of the book tends to be overloaded, so investigating if using sageplot for 3D may be something we look into. (There was also a day where the SageCellServer was down, which crippled our text.)

Disabling the QR codes could certainly be a feature request with possibly some design discussion around it. (For example, I imagine some texts will have sufficient margin space for the QR code to go into the margin, while others will have a page size that doesn’t leave much room for being in the margin. Some publishers may envision meaningful use of the PDF version in an electronic form, so the current triple of links might be useful for them. Other publishers want HTML to be the version used by readers on devices with PDF only for print, so just having the QR code will suffice. An option to configure the sidebyside that is produced for the static image and the QR code would be good as well.)

We are going to be shifting pretty seriously into thinking about the print version of ACM in the very near future, and getting good static versions (with minimal manual screenshotting) as well as a nice way for readers to access the interactive version will be a priority for us. 

Mitch

Juan Carlos Bustamante

unread,
Sep 10, 2026, 2:52:12 PMSep 10
to pretext...@googlegroups.com

Thanks Mitch, for your insight. 

So, at the end of the day, at this point, there is no way to obtain the nice figure one gets from sage one-cell server through an <interactive>, but directly from a <sageplot variant = "3d">. Am I right?

Does it make sense to ask for an improvement on the generation of <sageplot variant = "3d"> either by parsing the sage code to a one-cell server and then doing the screen shot in the usual way, do all this locally, from sage, but avoiding sage itself to save the figure? 

In any case, at this point I am quite stuck with this. Any suggestion?


JC

Rob Beezer

unread,
Sep 10, 2026, 2:56:40 PMSep 10
to pretext...@googlegroups.com
On 9/10/26 11:52, Juan Carlos Bustamante wrote:
> Any suggestion?

Copied from below, a suggestion which I do not think has been pursued at all.

>>>>> Our 3D plots from Sage have never been very good, and likely the code
>>>>> has not
>>>>> been touched in years. So maybe we need to use better Sage code.
>>>>> Encouraging
>>>>> authors to do extra work (manual screenshots) and override our automatic
>>>>> production does not sound like the first solution to try.
>>>>>
>>>>> Can we do something better (different Sage code) to get a better PNG
>>>>> (or other
>>>>> format) image? Have you experimented within Sage itself?

Rob
>>>> Figure 11.8.9 <https://activecalculus.org/multi/S-mv_deriv-
>>>> directional.html#DDexample2> in ACM is generated by xi:include of this file
>>>> <https://github.com/active-calculus/active-calculus-vector/blob/main/source/
>>>> interacts/DDExample2.txt> in this source file <https://github.com/active-
>>>> calculus/active-calculus-vector/
>>>> blob/692c03c893ec7fd28e23116fb65764197c6a4029/source/
>>>> S_mv_deriv_directional_deriv.ptx#L345>
>>>>
>>>> I didn’t actually know that one could use a sageplot with code for a 3D
>>>> image inside it, so this is how we’ve done all of ours.
>>>>
>>>> Mitch
>>>>
>>>>> On Sep 6, 2026, at 10:07 AM, Juan Carlos Bustamante <jotac...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> Dear Bob,
>>>>>
>>>>> Yes, the problem comes from the fact that sage uses tachyon to save the 3d
>>>>> figures (I think). In any case, when i do my figure in a jupyter notebook
>>>>> and use Fig.save(...) I get the poor image pretext uses to build the pdf.
>>>>> Since the figures obtained as a preview for  an "interactive" pointing to
>>>>> the sage one cell-server are quite good, I would say that this is the right
>>>>> mechanism. So is this a feature request? In the meanwhile, is there a
>>>>> workaround?
>>>>>
>>>>> JC
>>>>>
>>>>> Le sam. 5 sept. 2026, à 18 h 20, 'Rob Beezer' via PreTeXt support <pretext-
>>>>> sup...@googlegroups.com> a écrit :
>>>>> support%2Bunsu...@googlegroups.com> <mailto:pretext-
>>>>> > support+u...@googlegroups.com
>>>>> <mailto:support%2Bunsu...@googlegroups.com>>.
>>>>> > To view this discussion visit https://groups.google.com/d/msgid/
>>>>> pretext-support/
>>>>> > ef4649e2-39ac-4d63-bae9-e0329f1d9187n%40googlegroups.com
>>>>> <http://40googlegroups.com/> <https://
>>>>> > groups.google.com/d/msgid/pretext-support/ef4649e2-39ac-4d63-bae9-
>>>>> <http://groups.google.com/d/msgid/pretext-support/ef4649e2-39ac-4d63-
>>>>> bae9->
>>>>> > e0329f1d9187n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>> <http://40googlegroups.com/?utm_medium=email&utm_source=footer>>.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "PreTeXt support" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to pretext-suppo...@googlegroups.com
>>>>> <mailto:pretext-support%2Bunsu...@googlegroups.com>.
>>>>> To view this discussion visit https://groups.google.com/d/msgid/
>>>>> pretext-support/MTAwMDAxRC5PdHRjODk.1788646853%40pnsh.
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups
>>>>> "PreTeXt support" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an
>>>>> email to pretext-suppo...@googlegroups.com.
>>>>> To view this discussion visit https://groups.google.com/d/msgid/pretext-
>>>>> support/
>>>>> CAHyrz10aFCJemJ7KgOXX2BTJ3%3Dq7n4ric%2B8yjMSzveiHLEQ3hQ%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/pretext-support/
>>>>> CAHyrz10aFCJemJ7KgOXX2BTJ3%3Dq7n4ric%2B8yjMSzveiHLEQ3hQ%40mail.gmail.com?
>>>>> utm_medium=email&utm_source=footer>.
>>>>
>>>> --
>>>> Mitch Keller
>>>> mi...@rellek.net
>>>>
>>>> http://www.rellek.net/
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "PreTeXt support" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an
>>>> email to pretext-suppo...@googlegroups.com.
>>>> To view this discussion visit https://groups.google.com/d/msgid/pretext-
>>>> support/02B3229F-83C0-4AB1-9CFF-28EC5B139E76%40rellek.net <https://
>>>> groups.google.com/d/msgid/pretext-
>>>> support/02B3229F-83C0-4AB1-9CFF-28EC5B139E76%40rellek.net?
>>>> utm_medium=email&utm_source=footer>.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "PreTeXt support" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to pretext-suppo...@googlegroups.com.
>>> To view this discussion visit https://groups.google.com/d/msgid/pretext-
>>> support/aad2292b-2713-4584-8bcf-c59053cb6202%40gmail.com <https://
>>> groups.google.com/d/msgid/pretext-support/aad2292b-2713-4584-8bcf-
>>> c59053cb6202%40gmail.com?utm_medium=email&utm_source=footer>.
>>
>> --
>> Mitch Keller
>> mi...@rellek.net
>>
>> http://www.rellek.net/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PreTeXt support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pretext-suppo...@googlegroups.com.
>> To view this discussion visit https://groups.google.com/d/msgid/pretext-
>> support/F0250176-6A5B-467F-A89C-B9C3CBACC52C%40rellek.net <https://
>> groups.google.com/d/msgid/pretext-support/F0250176-6A5B-467F-A89C-
>> B9C3CBACC52C%40rellek.net?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> support/70eceae9-6086-47ef-9cd0-8a955ec4b8d1%40gmail.com <https://
> groups.google.com/d/msgid/pretext-
> support/70eceae9-6086-47ef-9cd0-8a955ec4b8d1%40gmail.com?
> utm_medium=email&utm_source=footer>.

Juan Carlos Bustamante

unread,
Sep 10, 2026, 3:01:32 PMSep 10
to pretext...@googlegroups.com
Hello Bob,

Sage, called by pretext exports that poor .png figure. I did not modify
my sage code significantly, since the figure looks god in the applet, in
a jupyter notebook, in the one-cell server. What should I try if I try
to modify the sage code?

On the other hand, I had no answer about the two possibilities I mention.


Thanks,


JC

Mitch Keller

unread,
Sep 14, 2026, 2:00:24 PMSep 14
to pretext...@googlegroups.com
I think Rob’s suggestion was that PreTeXt should try to do better. I went looking into the XSL. When you have a sageplot, there is a call to the .save method of the graphics object. For 3D graphics, it looks like there are two options for the viewer: Jmol (default) and Tachyon. Would allowing authors to do some settings on a 3D sageplot to use the other viewer or adjust settings be a useful thing for PreTeXt to provide?

kcri...@gmail.com

unread,
Sep 15, 2026, 1:16:14 PMSep 15
to PreTeXt support
I think Rob’s suggestion was that PreTeXt should try to do better. I went looking into the XSL. When you have a sageplot, there is a call to the .save method of the graphics object. For 3D graphics, it looks like there are two options for the viewer: Jmol (default) and Tachyon. Would allowing authors to do some settings on a 3D sageplot to use the other viewer or adjust settings be a useful thing for PreTeXt to provide?


One issue is that Sage's current default for *viewing* is interactive, threejs (https://doc.sagemath.org/html/en/reference/plot3d/threejs.html), but the main way to get a *static* image is still Tachyon, which has the less nice pngs (but is very useful for creating larger animations).  If you have a system where jmol is set up, it is (or was) also possible to save images by hand from there, but I don't know if there was a good automated way to do it.  

As to threejs, if you do a search for "headless screenshot" or similar things (see e.g. https://threejs.org/manual/#tips#screenshot) there might be some interesting leads there as well for how to automate something for PTX, which would be quite valuable.  I'm sure there are people on this list with expertise in things like puppeteer (or whatever the best current option is) who could whip something up.

Rob Beezer

unread,
Sep 15, 2026, 1:22:17 PMSep 15
to pretext...@googlegroups.com
Thanks, Mitch, for the translation/interpretation. That was exactly my intent.

JMOL! I'd forgotten about that. Some Java *molecule* viewer Sage used to
display 3D surfaces.

We are trying to fix LaTeX. We are not going to fix Sage as well. ;-)
#sageplot is great because you have a full spectrum of mathematical functions to
use. Asymptote and PreFigure are better choices for plots, I think. 3D exists
today for Asymptote and we can maybe cajole PreFigure to wander in that direction.

So we have whatever Sage gives us for 3D in static image formats. A first
suggestion would be to increase the resolution. I have not investigated the
missing labels yet.

Rob
>> support/bfcc41a7-408f-4449-9c95-5f97d73c300d%40gmail.com <https://
>> groups.google.com/d/msgid/pretext-support/
>> bfcc41a7-408f-4449-9c95-5f97d73c300d%40gmail.com>.
>
> --
> Mitch Keller
> mi...@rellek.net
>
> http://www.rellek.net/
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> ECE186B8-8F27-46AC-85F1-3E7A70925158%40rellek.net <https://groups.google.com/d/
> msgid/pretext-support/ECE186B8-8F27-46AC-85F1-3E7A70925158%40rellek.net?
> utm_medium=email&utm_source=footer>.

Rob Beezer

unread,
Sep 15, 2026, 1:27:08 PMSep 15
to pretext...@googlegroups.com
Thanks very much, KDC. Good to have some Sage-knowledge weigh in, mine is
likely out-of-date. (And our messages have just crossed paths.)

We do headless screenshots already for #interactive, and similar. I am very
reluctant to "improve" Sage by going that route. My *opinion* is we take what
Sage gives us, for better or worse, in sickness and in health, and if we want
to, we can pester Sage to do a better job. I can't imagine we are the only
folks after better static images of 3D objects.

Or authors use Asymptote, and down the road, PreFigure.

Rob
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/25256a29-4130-4bab-85a1-f21499b9ce75n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/25256a29-4130-4bab-85a1-
> f21499b9ce75n%40googlegroups.com?utm_medium=email&utm_source=footer>.

David Austin

unread,
Sep 15, 2026, 1:44:02 PMSep 15
to pretext...@googlegroups.com
3D exists today for Asymptote and we can maybe cajole PreFigure to wander in that direction.

Already wondering
 
Reply all
Reply to author
Forward
0 new messages