Python networkx.draw_spring() Examples

The following are 9 code examples of networkx.draw_spring(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module networkx , or try the search function .
Example #1
Source File: graphs.py    From textplot with MIT License 6 votes vote down vote up
def draw_spring(self, **kwargs):

        """
        Render a spring layout.
        """

        nx.draw_spring(
            self.graph,
            with_labels=True,
            font_size=10,
            edge_color='#dddddd',
            node_size=0,
            **kwargs
        )

        plt.show() 
Example #2
Source File: test_pylab.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_draw(self):
        try:
            N=self.G
            nx.draw_spring(N)
            plt.savefig("test.ps")
            nx.draw_random(N)
            plt.savefig("test.ps")
            nx.draw_circular(N)
            plt.savefig("test.ps")
            nx.draw_spectral(N)
            plt.savefig("test.ps")
            nx.draw_spring(N.to_directed())
            plt.savefig("test.ps")
        finally:
            try:
                os.unlink('test.ps')
            except OSError:
                pass 
Example #3
Source File: test_pylab.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_draw(self):
        try:
            functions = [nx.draw_circular,
                         nx.draw_kamada_kawai,
                         nx.draw_planar,
                         nx.draw_random,
                         nx.draw_spectral,
                         nx.draw_spring,
                         nx.draw_shell]
            options = [{
                'node_color': 'black',
                'node_size': 100,
                'width': 3,
            }]
            for function, option in itertools.product(functions, options):
                function(self.G, **option)
                plt.savefig('test.ps')

        finally:
            try:
                os.unlink('test.ps')
            except OSError:
                pass 
Example #4
Source File: test_pylab.py    From aws-kube-codesuite with Apache License 2.0 6 votes vote down vote up
def test_draw(self):
        try:
            functions = [nx.draw_circular,
                         nx.draw_kamada_kawai,
                         nx.draw_random,
                         nx.draw_spectral,
                         nx.draw_spring,
                         nx.draw_shell]
            options = [{
                           'node_color': 'black',
                           'node_size': 100,
                           'width': 3,
                       }]
            for function, option in itertools.product(functions, options):
                function(self.G, **option)
                plt.savefig('test.ps')

        finally:
            try:
                os.unlink('test.ps')
            except OSError:
                pass 
Example #5
Source File: test_pylab.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_edge_colormap(self):
        colors = range(self.G.number_of_edges())
        nx.draw_spring(self.G, edge_color=colors, width=4,
                       edge_cmap=plt.cm.Blues, with_labels=True)
        plt.show() 
Example #6
Source File: test_pylab.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_arrows(self):
        nx.draw_spring(self.G.to_directed())
        plt.show() 
Example #7
Source File: multi_circuit.py    From GridCal with GNU General Public License v3.0 5 votes vote down vote up
def plot_graph(self, ax=None):
        """
        Plot the grid.
        :param ax: Matplotlib axis object
        :return:
        """
        if ax is None:
            fig = plt.figure()
            ax = fig.add_subplot(111)

        if self.graph is None:
            self.build_graph()

        nx.draw_spring(self.graph, ax=ax) 
Example #8
Source File: test_pylab.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_edge_colormap(self):
        colors = range(self.G.number_of_edges())
        nx.draw_spring(self.G, edge_color=colors, width=4,
                       edge_cmap=plt.cm.Blues, with_labels=True)
        plt.show() 
Example #9
Source File: test_pylab.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_arrows(self):
        nx.draw_spring(self.G.to_directed())
        plt.show()