我想输出通过将graphviz2 perl模块用于文件生成的图。我有下一个代码,但不能保存图像。我该如何保存?
my $output_dir = "/home/user/Desktop/output.png";
my($graph) = GraphViz2 -> new ();
(
edge => {color => 'grey'},
global => {directed => 1},
graph => {label => 'Adult', rankdir => 'TB'},
logger => $logger,
node => {shape => 'oval'},
);
$graph -> add_node(name => 'Carnegie', shape => 'circle');
$graph -> add_node(name => 'Murrumbeena', shape => 'box', color => 'green');
$graph -> add_node(name => 'Oakleigh', color => 'blue');
$graph -> add_edge(from => 'Murrumbeena', to => 'Carnegie', arrowsize => 2);
$graph -> add_edge(from => 'Murrumbeena', to => 'Oakleigh', color => 'brown');
my($format) = shift || 'png';
my($output_dir) = shift || File::Spec -> catfile('png', "sub.graph.$format");
$graph -> run(format => $format, output_file => $output_file);
my($output_dir) = shift || File::Spec -> catfile('png', "sub.graph.$format");
应该是
my($output_file) = shift || File::Spec -> catfile('html', "sub.graph.$format");
您的代码没有$output_file
,您从某个地方错误地制作了错字或复制/粘贴代码。