how display labels edges and color with dictionary?
Hi
How can I label edges style :edge (0,1) ='01' and give them a color like in the simplex1ColorRevDic
dictionary ?
# functions
def strListToList(strL) :
Lstr=strL.replace('[','').replace(']','').split(',')
return [SR(e) for e in Lstr]
def addAxis(plt,textToPlt,xBound,yBound,zBound,wA,rA) :
# add axis for real part
plt += arrow3d((0, 0, 0), (xBound, 0, 0), color='red',width=wA,radius=rA)
plt += text3d("ex", (xBound, 0, 0), fontsize='200%', color='black')
plt += arrow3d((0, 0, 0), (0, yBound, 0), color='gray',width=wA,radius=rA)
plt += text3d("ey", (0, yBound, 0), fontsize='200%', color='gray')
plt += arrow3d((0, 0, 0), (0, 0, zBound), color='pink',width=wA,radius=rA)
plt += text3d("ez", (0,0, zBound), fontsize='200%', color='pink')
plt+=textToPlt
return plt
xBound=1.5 ;yBound=1.5 ;zBound=1.5
shiftV=vector([1/10,1/10,1/10])
widthA=0.2 ;radiusA=0.02
textToPlt = text3d("test",vector( (xBound, yBound, 1.5*zBound))+shiftV, fontsize='300%', fontweight=800)
g = DiGraph()
cubeDic={0: [0, 0, 0],1: [1, 0, 0], 2: [0, 1, 0], 3: [1, 1, 0] ,
4: [0, 0, 1], 5: [1, 0, 1], 6: [0, 1, 1], 7: [1, 1, 1]}
simplex0=[ 0, 1, 2, 3, 4, 5, 6, 7 ]
simplex1=[[0, 4], [0, 5], [0, 6], [4, 5], [4, 6],
[5, 6], [0, 1], [0, 3], [0, 7], [1, 3],
[1, 7], [3, 7], [1, 5], [5, 7], [0, 2],
[2, 3], [2, 6], [3, 6], [6, 7]]
colorPaletteSimplex1=rainbow(len(simplex1))
simplex1ColorDic={}
for v,c in zip(simplex1,colorPaletteSimplex1):
simplex1ColorDic[str(v)]=str(c)
keys=[simplex1ColorDic.get(k) for k in simplex1ColorDic.keys()]
values=[strListToList(s1)for s1 in simplex1ColorDic.keys()]
simplex1ColorRevDic=dict(zip(keys,values))
g.add_vertices( simplex0 )
g.add_edges(simplex1)
g.set_edge_label((0,1),'toto',(0,0.5,0))
g.set_pos(cubeDic,dim=3)
print('positions :',g.get_pos(dim=3))
#gPlt=g.plot3d(save_pos=True,edge_colors=simplex1ColorRevDic) #errors !
gPlt=g.plot3d(save_pos=True,edge_labels=True)
gPlt=addAxis(gPlt,textToPlt,xBound,yBound,zBound,widthA,radiusA)
gPlt.show()
It seems that plot3d is not able to display the labels .