labeling vertices of polyhedron

34 views
Skip to first unread message

Emily G

unread,
Nov 3, 2017, 12:15:58 PM11/3/17
to sage-support
Is it possible to add vertex labels when I plot Polyhedron? For example, below is my code for displaying a polytope, and I would like to be able to see the labels (1,1,1), (1,1,2), etc for all the corresponding vertices. (I am doing this in CoCalc) 

f=[
[1,1,1],
[ 1,1,2 ],
[ 1,2,1 ],
[ 1,2,3 ],
[ 1,3,2 ],
[ 2,1,1 ],
[ 2,1,2 ],
[ 2,3,1 ],
[ 2,3,4 ],
[ 2,5,3 ],
[ 3,2,1 ],
[ 3,2,3 ],
[ 3,5,2 ],
[ 4,3,2 ]
]
F=Polyhedron(vertices=f)
F.plot(point={'color':'red'})





egunawan

unread,
Nov 3, 2017, 1:06:52 PM11/3/17
to sage-support
I found out about text3d and use that to add labels. 

g=F.plot(point={'color':'red'})
T=[text3d("{}".format(pt),pt) for pt in f]
labels = T[0]
for i in range(len(T)-1):
    labels = labels + T[i+1]
show(g+labels)


Reply all
Reply to author
Forward
0 new messages