Moving the nodes with Mouse

1,681 views
Skip to first unread message

satyam

unread,
May 15, 2011, 8:56:55 PM5/15/11
to networkx-discuss
Hi I am looking for some way to move the nodes of network by clicking
the mouse, like the way its done in gephi. Can anyone provide some
idea on how to do this.
Thanks
Satyam

Aric Hagberg

unread,
May 15, 2011, 9:37:02 PM5/15/11
to networkx...@googlegroups.com

It's possible with Matplotlib but you'lll have to write some code. See
http://matplotlib.sourceforge.net/users/event_handling.html
for details.

Aric

satyam mukherjee

unread,
Jun 2, 2011, 5:51:33 PM6/2/11
to networkx...@googlegroups.com
Thanks for this link. It was really helpful. Is there any example for dragging nodes (say even for a scatter plot would be of great help)
Thanks
Satyam


--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.




--
-------------------------------------------
WHEN LIFE GIVES U HUNDRED REASONS TO CRY,SHOW LIFE THAT U HAVE THOUSAND REASONS TO SMILE :-)

satyam mukherjee
224-436-3672 (Mob)
847-491-7238 (Off)

Aric Hagberg

unread,
Jun 2, 2011, 6:10:00 PM6/2/11
to networkx...@googlegroups.com
On Thu, Jun 2, 2011 at 3:51 PM, satyam mukherjee <dira...@gmail.com> wrote:
> Thanks for this link. It was really helpful. Is there any example for
> dragging nodes (say even for a scatter plot would be of great help)

http://matplotlib.sourceforge.net/examples/event_handling/index.html

Aric

satyam mukherjee

unread,
Jun 3, 2011, 7:43:20 PM6/3/11
to networkx...@googlegroups.com

Thanks. Here is an example of a code which I wrote using the event handling codes in matplotlib.

I would like to have the nodes colored according to some weights and also assign different marker for different weights...e.g. 'o' for -ve weights and 's' for +ve weights. I think I have to edit the following portion of the code


    def __init__(self, pathpatch):

        self.ax = pathpatch.axes
        canvas = self.ax.figure.canvas
        self.pathpatch = pathpatch
        self.pathpatch.set_animated(True)

        x, y = zip(*self.pathpatch.get_path().vertices)

        self.line, = ax.plot(x,y,color='gray',marker='o', markerfacecolor='r',animated=True)

        self._ind = None # the active vert

        canvas.mpl_connect('draw_event', self.draw_callback)
        canvas.mpl_connect('button_press_event', self.button_press_callback)
        canvas.mpl_connect('key_press_event', self.key_press_callback)
        canvas.mpl_connect('button_release_event', self.button_release_callback)
        canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
        self.canvas = canvas

Not sure how to implement. Can any one help me. Also am attaching the example.





Aric

--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.

nx_example_event.py

Aric Hagberg

unread,
Jun 3, 2011, 8:11:05 PM6/3/11
to networkx...@googlegroups.com
On Fri, Jun 3, 2011 at 5:43 PM, satyam mukherjee <dira...@gmail.com> wrote:
>
> Thanks. Here is an example of a code which I wrote using the event handling
> codes in matplotlib.
>
> I would like to have the nodes colored according to some weights and also
> assign different marker for different weights...e.g. 'o' for -ve weights and
> 's' for +ve weights. I think I have to edit the following portion of the
> code
>
> Not sure how to implement. Can any one help me. Also am attaching the
> example.

You might have better luck asking on the matplotlib mailing list since
your question is about the use of patch properties with matplotlib.

What you'll need to do is modify the mpatches.PathPatch part to change
the color and shape of the patch. (Or alternatively use some of the
predefined patches like Circle).

Aric

satyam mukherjee

unread,
Jun 5, 2011, 6:29:38 PM6/5/11
to networkx...@googlegroups.com
Ok not much luck. But is there a short cut plotting the network in gephi. Let me put it from the start. I have gml file with node attributes. The attributes are in the form of weights (which are negative as well as positive values). Right now I am plotting the network, coloring the nodes according to the weights as well as giving shapes to the nodes - say square for +ve weight ans circle for -ve weight. So is there a way to write this same graph in gexf format (with the same attributes) and plot the network in Gephi.
Thanks


Aric

--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.

Aric Hagberg

unread,
Jun 5, 2011, 6:38:15 PM6/5/11
to networkx...@googlegroups.com
On Sun, Jun 5, 2011 at 4:29 PM, satyam mukherjee <dira...@gmail.com> wrote:
> Ok not much luck. But is there a short cut plotting the network in gephi.
> Let me put it from the start. I have gml file with node attributes. The
> attributes are in the form of weights (which are negative as well as
> positive values). Right now I am plotting the network, coloring the nodes
> according to the weights as well as giving shapes to the nodes - say square
> for +ve weight ans circle for -ve weight. So is there a way to write this
> same graph in gexf format (with the same attributes) and plot the network in

I think Gephi reads GraphML and GEXF format files (probably others).
So you could try that.

Aric

Simon Knight

unread,
Jun 6, 2011, 12:25:11 AM6/6/11
to networkx...@googlegroups.com
Satyam:
What do you need to achieve with the interactivity?
You can easily plot static plots in NetworkX using Matplotlib.
You can also draw your graph in a different program such as yEd and
import it into NetworkX using GML or GraphML.

cheers
Simon

Reply all
Reply to author
Forward
0 new messages