使用perl画图
来源:互联网 发布:手机淘宝可以比价吗 编辑:程序博客网 时间:2024/05/16 00:30
zz :http://stackoverflow.com/questions/18150841/gdgraph-with-perl
GD::Graph with Perl
Assuming your data file is as follows, using tab delimiters.
Student Name ScoreJack 89Jill 70Sandy 40
You could do something like this, pushing your x
axis and y
axis values from your data file to arrays.
use strict;use warnings;use CGI qw( :standard );use GD::Graph::bars;open my $fh, '<', 'data.txt' or die $!;my (@x, @y);while (<$fh>) { next if $. == 1; # skip header line push @x, (split /\t/)[0]; # push 'Student Names' into @x array push @y, (split /\t/)[1]; # push 'Score' into @y array}close $fh;my $graph = GD::Graph::bars->new(800, 800);$graph->set( x_label => 'Students', y_label => 'Scores', title => 'Student Vs. Scores',) or warn $graph->error;my @data = (\@x, \@y);$graph->plot(\@data) or die $graph->error();print header(-type=>'image/jpeg'), $graph->gd->jpeg;
Giving you for example:
If you are wanting to use multiple y
axis values, assuming you have another tab delimiter column with for example Score2
, you could easily do something like this.
my (@x, @y, @y2);while (<$fh>) { next if $. == 1; push @x, (split /\t/)[0]; push @y, (split /\t/)[1]; push @y2, (split /\t/)[2];}
And change your @data
array to:
my @data = (\@x, \@y, \@y2);
And your result would be:
0 0
- 使用perl画图
- perl实现excel画图和写文件
- perl实现excel画图和写文件
- perl使用
- 使用jpgraph画图
- 使用SurfaceView即时画图
- 使用Python Pychart画图
- C# 使用Graphics画图
- C# 使用MSChart画图
- php使用graphviz画图
- 使用画刷画图
- android 使用shape画图
- Python使用ReportLab画图
- Android使用SurfaceView画图
- 使用ggplot2画图
- Windows画图使用总结
- 使用ggplot2画图
- 使用ggplot2画图
- 可是有的时候真的是太在乎,太容易受伤了。
- NYOJ-63 小猴子下落
- 新浪fragment实现tab,但不能滑动
- 从程序员到技术总监,分享10年开发经验
- [Java] 监控java对象回收的原理与实现
- 使用perl画图
- linux--tomcat自动重启--shell编程
- HDU4801DP,异或运算,与运算,hash的应用
- Unity 3D 技巧集合
- Java三大特性
- 可是有的时候真的是太在乎,太容易受伤了。
- final关键字
- poi 导出Excel
- LeetCode 070 Climbing stairs