我有一个名为@V_list
的列表。我创建了另一个与@V_list
大小相同的列表,即@nn
。现在,我想绘制一个@nn
vs @V_list
的图。这是我使用的代码,但是在my $gd = $graph->plot(\@nn,\@V_list) or die "Can't plot graph";
中出现错误。如何完成?
use GD;
use GD::Graph::lines;
@V_list=(1,2,1,2);
print "@V_list\n";
$size = @V_list;
@nn=1..$size;
print "@nn\n";
my $graph = new GD::Graph::lines( );
my $gd = $graph->plot(\@nn,\@V_list) or die "Can't plot graph";
open(IMG, '>file.png') or die $!;
binmode IMG;
print IMG $gd->png;
close IMG;
答案 0 :(得分:2)
GD::Graph::plot
方法https://documize.github.io/ad-ldap-test-server/。调用语法应类似于
$graph->plot( [ \@nn, \@V_list ] )
代替
$graph->plot( \@nn, \@V_list )