Change the color of a node by graphml file

287 views
Skip to first unread message

BELLAFKIH hayat

unread,
Jun 16, 2016, 11:29:38 PM6/16/16
to cytoscape-helpdesk
Hello,
 I am using cytoscape to visualize a graph by using the graphml format. i like to change the style of only one node. I find this example:
<?xml version="1.0" encoding="UTF-8"?>
      xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns 
  <key id="d0" for="node" attr.name="color" attr.type="string">
    <default>yellow</default>
  </key>
  <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
  <graph id="G" edgedefault="undirected">
    <node id="n0">
      <data key="d0">green</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">blue</data>
    </node>
    <node id="n3">
      <data key="d0">red</data>
    </node>
    <node id="n4"/>
    <node id="n5">
      <data key="d0">turquoise</data>
    </node>
    <edge id="e0" source="n0" target="n2">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e1" source="n0" target="n1">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e2" source="n1" target="n3">
      <data key="d1">2.0</data>
    </edge>
    <edge id="e3" source="n3" target="n2"/>
    <edge id="e4" source="n2" target="n4"/>
    <edge id="e5" source="n3" target="n5"/>
    <edge id="e6" source="n5" target="n4">
      <data key="d1">1.1</data>
    </edge>
  </graph>
</graphml>

but when i import the file in cytoscape, the color of nodes was overrided by the default style. 

thanks in advance.

Scooter Morris

unread,
Jun 23, 2016, 10:51:06 AM6/23/16
to cytoscape-helpdesk
Hi,
   Sure -- all you're doing is importing a new column called "color".  There isn't anything magic about a column named color (it could be called "MyLook" or whatever).  Once you've imported your file, just go to the Style panel and set the Fill Color to be a passthrough mapping from your column.   As long as Cytoscape understands the Color names, it will "just work".

-- scooter

BELLAFKIH hayat

unread,
Jun 23, 2016, 12:19:09 PM6/23/16
to cytoscape...@googlegroups.com
Hi,
it work. great thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/F0pBQxGiH_Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
For more options, visit https://groups.google.com/d/optout.



--
Hayat BELLAFKIH
" Le succès n’est pas la clé du bonheur. Le bonheur est la clé du succès. Si vous aimez ce que vous faites, vous réussirez ".
Albert Schweitzer
Reply all
Reply to author
Forward
0 new messages