Perl使用GD生成曲线图
#!/usr/bin/perl -w use GD::Graph::lines; @data=( [(0,1,...
扫描右侧二维码阅读全文
14
2009/01

Perl使用GD生成曲线图

#!/usr/bin/perl -w use GD::Graph::lines; @data=( [(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26)], [(6,7,10,14,20,26,32,38,46,54,62,70,76,80,84,86,88,90,92,93,94,95,96,96,96,96,96)], ); $my_graph = new GD::Graph::lines(800,300); $my_graph->set( x_label => 'weeks', y_label => 'visitors', itle => 'Title', transparent => 0, ); $my_graph->plot(\@data); save_chart($my_graph, 'edit1'); sub save_chart { my $chart = shift or die "Need a chart!"; my $name = shift or die "Need a name!"; local(*OUT); my $ext = $chart->export_format; open(OUT, ">$name.$ext") or die "Cannot open $name.$ext for write: $!"; binmode OUT; print OUT $chart->gd->$ext(); close OUT; }

Last modification:November 26th, 2018 at 04:16 pm
If you think my article is useful to you, please feel free to appreciate

One comment

  1. 变压器

    高手 高手

Leave a Comment