[英]Matplotlib fetching irregular shape
This displays a node which is a figure using networkx
and matplotlib
: 这将显示一个节点,该节点是使用
networkx
和matplotlib
的图形:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
n = "%%%%% \n% % % \n%%%%%"
print n
G.add_node(n)
nx.draw(G)
plt.show()
print n
displays: print n
显示:
%%%%%
% % %
%%%%%
plt.show()
displays: plt.show()
显示:
%%%%%
%%%
%%%%%
The data is very large so i can't edit n and rearrange it for desired output. 数据非常大,所以我无法编辑n并将其重新排列为所需的输出。 How can I code such that both the shapes are equal?
如何编码使两个形状相等?
You can set n again with a differently formated string: 您可以使用不同格式的字符串再次设置n:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
n = "%%%%% \n% % % \n%%%%%"
print n
n = n.replace(" ", " ")
G.add_node(n)
nx.draw(G)
plt.show()
And you will get the following figure 你会得到下图
and output:
并输出:
%%%%%
% % %
%%%%%
Or is there any reason that you did not specify why this does not work? 还是有任何原因您没有指定为什么它不起作用?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.