lt_model.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:latenttrees 作者: kaltwang 项目源码 文件源码
def draw_axes(self, ax=None, id_highlight=None):
        # plt.ion()  # interactive mode on (doesn't work with pycharm)
        g = self.__nxgraph
        # new call format for networkx 1.11 (uses pygraphviz, which does not support Python 3!)
        # pos = nx.drawing.nx_agraph.graphviz_layout(g, prog='dot')
        # old call format for networkx 1.10
        # pos = nx.graphviz_layout(g, prog='dot')
        # new call format for networkx 1.11 (uses pydot)
        pos = nx.drawing.nx_pydot.graphviz_layout(g, prog='dot')

        if ax is None:
            ax = self.get_axes(self.id_axes)
        assert len(ax) == self.required_axes

        nx.draw(g, pos, ax=ax[0], hold=True, with_labels=True, arrows=True)
        # nx.draw_networkx(self.__graph)

        # plot the roots
        if id_highlight is None:
            id_highlight = self.__id_roots
        for r in id_highlight:
            ax[0].scatter(pos[r][0], pos[r][1], s=500)

        for id_node, node in self.nodes_iter(data=True):
            c = "{}".format(node.layer)
            ax[0].text(pos[id_node][0], pos[id_node][1], "\n" + c, va='top', ha='center', color='blue')

        # plt.show()  # this call blocks further execution until window is closed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号