(LaTeX/dot2tex) view posets with edge and vertex labels

25 views
Skip to first unread message

Martin R

unread,
Nov 2, 2021, 2:37:34 PM11/2/21
to sage-support
is it possible to display a poset with (LaTeX) labels on the covering relations and (LaTeX) labels on the vertices?

For example:

sage: P = Poset([[1,2,3,4], [[1,2], [2,3], [1,4]]])
sage: e = {i: "$q^%s$" % i for i in P}
sage: c = {(i,j): "$%s^%s$" % (i, j) for i, j in P.cover_relations()}
sage: P.plot(element_labels=e, cover_labels=c)

This almost works.  Unfortunately, the layout is not the dot2tex layout, which I need because my posets are large, and it displays 'None' instead of the edge label.

Martin

Martin R

unread,
Nov 3, 2021, 4:17:04 AM11/3/21
to sage-support
Sorry for answering my own question.

It seems that

sage: P = Poset([[1,2,3,4], [[1,2], [2,3], [1,4]]])
sage: e = {i: LatexExpr("q^%s" % i) for i in P}
sage: c = {(i,j): LatexExpr("%s^%s" % (i, j)) for i, j in P.cover_relations()}

sage: H = P.hasse_diagram()
sage: [H.set_edge_label(v1, v2, c[(v1, v2)]) for v1, v2 in P.cover_relations()]
sage: H.relabel({v: e[v] for v in P})
sage: H.set_latex_options(format="dot2tex", edge_labels=True)
sage: view(H)

works.

Henri Girard

unread,
Nov 3, 2021, 5:21:10 AM11/3/21
to sage-s...@googlegroups.com

I didn't not understand your question, I am french.

But I use show(LatexExpr(r" c'est  \ en \ français") ) for the text

show(LatexExpr(r" \sqrt x^2") ) for maths and I obtain nice things

--
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 on the web visit https://groups.google.com/d/msgid/sage-support/91981ecf-1172-4a75-8f4e-8189aa83502bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages