title in plot

39 views
Skip to first unread message

vdelecroix

unread,
May 19, 2026, 3:53:32 PM (4 days ago) May 19
to sage-support
Dear all,

I am fighting with title in graphics object. Is there a way to store a title in a graphics object ? For example one could consider Graphics() or graphs.PetersenGraph().plot(). This works fine with show at display time

sage: Graphics().show(title="empty plot")
sage: graphs.PetersenGraph().plot().show(title="Petersen graph")

But I want to store the title inside the graphics object as one would do with

sage: plot(x, title="x plot")

The reason is that I want a graphics_array containing various plots that do not accept a title argument. Ideally, something like the following would work but it does not

sage: G0 = Graphics()
sage: G0.set_title("empty plot")
sage: G1 = graphs.PetersenGraph().plot()
sage: G1.set_title("Petersen graph")
sage: graphics_array([G0, G1]).show()

Once again, it works like a charm for

sage: graphics_array([plot(x, title="x plot"), plot(x^2, title="x^2 plot")])

Best
Vincent

vdelecroix

unread,
May 19, 2026, 4:00:31 PM (4 days ago) May 19
to sage-support
Looking at the code I somehow found an ugly workaround

sage: G = graphs.PetersenGraph().plot()
sage: G._extra_kwds["title"] = "Petersen graph"
sage: G.show()

I think such a feature deserves a nicer user interface! Or did I miss the actual interface?

Best
Vincent

kcrisman

unread,
May 20, 2026, 7:15:18 AM (3 days ago) May 20
to sage-support
Hmm, this is all a good point.  At https://doc.sagemath.org/html/en/reference/plotting/sage/graphs/graph_plot.html#sage.graphs.graph_plot.GraphPlot.plot we see "The options accepted by this method are to be found in the documentation of the sage.graphs.graph_plot module, and the show() method." and of course the show method links to the actual graphics show method, so that for instance

sage: G.show(title="test")

works.  However, I agree that this is obscure at best for anyone only using graph plotting.

I think that one easy course of action is adding a few examples to the graph plot documentation that show off title (and anything else obviously useful).  Exposing more options directly in the graph plot interface of G.[tab] would require some careful thought. For example,

sage: G.show(xmin=1)

has what I deem to be a surprising output :-)

Vincent Delecroix

unread,
May 20, 2026, 7:36:38 AM (3 days ago) May 20
to sage-s...@googlegroups.com
Thanks Karl-Dieter. Note that setting title is not only restricted to
graph plots but more generally any plot.

I just noticed another annoying feature (this time of graphics_array)

sage: G0 = graphs.PetersenGraph().plot()
sage: G1 = graphs.CycleGraph(5).plot()
sage: G2 = graphs.CompleteGraph(5).plot()
sage: graphics_array([G0, G1, G2]).show(title="my favorite graphs")
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-support/528a74a5-c16f-4db3-b408-3fd98f8409afn%40googlegroups.com.

kcrisman

unread,
May 21, 2026, 7:14:48 AM (2 days ago) May 21
to sage-support
On Wednesday, May 20, 2026 at 7:36:38 AM UTC-4 vdelecroix wrote:
Thanks Karl-Dieter. Note that setting title is not only restricted to
graph plots but more generally any plot.

I just noticed another annoying feature (this time of graphics_array)

sage: G0 = graphs.PetersenGraph().plot()
sage: G1 = graphs.CycleGraph(5).plot()
sage: G2 = graphs.CompleteGraph(5).plot()
sage: graphics_array([G0, G1, G2]).show(title="my favorite graphs")

Haha, that is actually a feature - see https://github.com/sagemath/sage/issues/27865 and some related tickets, or  https://doxdrum.wordpress.com/2010/08/12/graphics-array-in-sagemath/ for the previous behavior and the workaround that was necessary then.  But https://github.com/sagemath/sage/issues/10656 probably is still worth working on with respect to this and I added your example - though I don't know what the "correct" default should be.
Reply all
Reply to author
Forward
0 new messages