【发布时间】:2011-06-19 13:13:04
【问题描述】:
我制作的图表具有巨大的宽度比:它们的大小为 51706 x 503 像素。 如何告诉 GraphViz 优化宽度?
注 1:该图实际上是一棵树,每个节点都有很多子节点。 这是sample。
注 2:我想我使用点 :)
注3:这里是Ruby code
def graph_node(n, parent=nil, depth=0)
#print n, " "
gn = @g.add_node(n.object_id.to_s, :label=>n.to_graphviz, :shape=>"Mrecord")
if parent
e = @g.add_edge(parent, gn)
end
if n == @current_pos_node
gn[:color] = "brown3"
gn[:style] = "filled"
elsif @s.tree.pv(@current_pos_node).include?(n)
gn[:color] = "cadetblue"
gn[:style] = "filled"
elsif @s.tree.pv(@root).include?(n)
gn[:color] = "yellow"
gn[:style] = "filled"
end
return if !n.children # or depth == 2
i = 0
for c in n.children
graph_node(c, gn, depth+1)
i += 1
#break if i > 2
end
end
def graph(name="tree", root_node=@current_pos_node)
@g = GraphViz::new("G")
#@g['sep'] = "10,100"
#@g["overlap"] = "compress"
#@g["rankdir"] = "BT"
#@g["ratio"] = "0.9"
@g["size"] = "350,500"
graph_node(root_node)
@g.output(:svg => "#{name}.svg")
end
【问题讨论】:
-
哪种布局 - 点式还是净式?你有样品吗?
-
点我想:) Here is a sample
-
我正在考虑生成图像(点文件)的代码示例。但从链接到的图片来看,
ratio="compress"和size应该会产生较小的结果。另外,您是否尝试过其他布局(neato)?使用neato 的结果可能更有趣。 -
我通过 Ruby 使用 GraphViz。我没有相应的 GraphViz 代码。这就是为什么我不知道我是否真的在使用 dot。现在我很确定我正在使用 dot。
-
这里是 Ruby 代码:gist.github.com/1062005