Pygraphviz xlabel position and color doesn't work

廉价感情. 提交于 2021-02-19 04:15:16

问题


I am using pygraphviz to create graphs for my project. I am unable to figure out how to center the xlabel of nodes and also how to change the color of xlabel.

graph.add_node(row[3], color='goldenrod2', style='filled', shape='box',
                           xlabel=round(self.pi_dict.get(row[3]), 2), fontname='calibri')

I tried using xlp='10,10!'and xlabelfontcolor='red'. Both attributes don't seem to work. Where am I going wrong.

enter image description here

As you can see in the attached fig. above, the xlabel is positioned by default towards the left corner of the nodes. Also by changing the color of xlabel, it can be easily distinguished from other labels, which I am unable to accomplish.


回答1:


There is no way to specify the position of an external label. (At some point, we hope to provide some support for this.) We didn't provide an xlabelfontcolor attribute as this can be handled via HTML-like labels. Indeed, since you want the external label centered above this node, this can also be used to solve your first problem. For example,

a [shape=none label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR><TD><FONT COLOR="red">0.19</FONT></TD></TR>
<TR><TD CELLPADDING="6" BGCOLOR="goldenrod2" PORT="p1">would</TD></TR></TABLE>>]

b -> a:p1:n

The PORT attribute is used to get the edge to end at the yellow box.



来源:https://stackoverflow.com/questions/16265541/pygraphviz-xlabel-position-and-color-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!