[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Help with write_svg function
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Help with write_svg function |
Date: |
Tue, 13 Apr 2010 16:45:58 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Tue, Apr 13, 2010 at 05:33:25PM +0200, Domenico Conti wrote:
> Hi, I use the following code:
>
> outFolder = self.mainView.outputFolderText.GetLabelText()
>
> fileName = outFolder+os.sep+"GRAPH_"+self.fileName+".svg"
>
> soglia = int(self.mainView.thresholdText.GetValue())
>
> graph.layout("kamada_kawai")
>
> graph.es["edge_color"]=[["red", "black"][value>soglia] for value in
> graph.es["iFlow"]]
>
> for vertex in graph.vs:
>
> vertex["vertex_color"] = "green"
>
> visualStyle = {}
>
> visualStyle["margin"] = 20
>
> visualStyle["layout"] = "kamada_kawai"
>
> visualStyle["edge_color"] = [["red", "black"][value>soglia] for value in
> graph.es["iFlow"]]
>
> visualStyle["vertex_color"] = "green"
>
> graph.write_svg(fileName, layout="kamada_kawai")
>
> but when I open svg file I can see that my visualStyle are not applied to my
> graph. Why?
Well, first, because you did not pass it to graph.write_svg; second,
because visualStyle["vertex_color"] must contain as many entries as the
number of vertices in your graph (even if all vertices must have the
same color). So, I'd do this:
visualStyle["vertex_color"] = ["green"] * graph.vcount()
graph.write_svg(fileName, **visualStyle)
Also note that the write_svg method is sort of deprecated; it was meant
to be used in earlier igraph versions when we did not have a proper
plotting support using Cairo. You should use plot(graph, fileName,
**visualStyle) instead, it will automatically know to use the SVG format
because of the file extension. Don't use write_svg unless you cannot
install the Python bindings of Cairo.
--
Tamas