使用Perl绘制统计图
来源:互联网 发布:沈伟 知乎 编辑:程序博客网 时间:2024/04/30 03:03
Bar
#!/use/bin/perl
use SVG::TT::Graph::Bar;
my @fields = qw(Jan Feb Mar);
my @data_sales_02 = qw(12 45 21);
my $graph = SVG::TT::Graph::Bar->new(
{
'height' => '500',
'width' => '300',
'fields' => \@fields,
}
);
$graph->add_data(
{
'data' => \@data_sales_02,
'title' => 'Sales 2002',
}
);
open( my $fh, '>', "bar.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
BarHorizontal
#!/use/bin/perluse SVG::TT::Graph::BarHorizontal;
my @fields = qw(Jan Feb Mar);
my @data_sales_02 = qw(12 45 21);
my $graph = SVG::TT::Graph::BarHorizontal->new(
{
'height' => '500',
'width' => '300',
'fields' => \@fields,
}
);
$graph->add_data(
{
'data' => \@data_sales_02,
'title' => 'Sales 2002',
}
);
open( my $fh, '>', "barhorizontal.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
BarLine
#!/use/bin/perluse SVG::TT::Graph::BarLine;
my @fields = qw(Jan Feb Mar);
my @data_sales_02 = qw(12 45 21);
my @data_sales_03 = ( 24, 55, 61 );
my $graph = SVG::TT::Graph::BarLine->new(
{
'height' => '500',
'width' => '300',
'fields' => \@fields,
}
);
$graph->add_data(
{
'data' => \@data_sales_02,
'title' => 'Sales 2002',
}
);
$graph->add_data(
{
'data' => \@data_sales_03,
'title' => 'Sales 2003',
}
);
open( my $fh, '>', "barline.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
LINE
#!/use/bin/perluse SVG::TT::Graph::Line;
my @fields = qw(Jan Feb Mar);
my @data_sales_02 = qw(12 45 21);
my @data_sales_03 = qw(15 30 40);
my $graph = SVG::TT::Graph::Line->new(
{
'height' => '500',
'width' => '300',
'fields' => \@fields,
}
);
$graph->add_data(
{
'data' => \@data_sales_02,
'title' => 'Sales 2002',
}
);
$graph->add_data(
{
'data' => \@data_sales_03,
'title' => 'Sales 2003',
}
);
open( my $fh, '>', "line.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
Pie
#!/use/bin/perluse SVG::TT::Graph::Pie;
my @fields = qw(Jan Feb Mar);
my @data_sales_02 = qw(12 45 21);
my $graph = SVG::TT::Graph::Pie->new(
{
'height' => '500',
'width' => '300',
'fields' => \@fields,
}
);
$graph->add_data(
{
'data' => \@data_sales_02,
'title' => 'Sales 2002',
}
);
open( my $fh, '>', "pie.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
TimeSeries
#!/use/bin/perluse SVG::TT::Graph::TimeSeries;
my @data_cpu = (
'2003-09-03 09:30:00', 23, '2003-09-03 09:45:00', 54,
'2003-09-03 10:00:00', 67, '2003-09-03 10:15:00', 12
);
my @data_disk = (
'2003-09-03 09:00:00', 12, '2003-09-03 10:00:00', 26,
'2003-09-03 11:00:00', 23
);
my $graph = SVG::TT::Graph::TimeSeries->new(
{
'height' => '500',
'width' => '300',
}
);
$graph->add_data(
{
'data' => \@data_cpu,
'title' => 'CPU',
}
);
$graph->add_data(
{
'data' => \@data_disk,
'title' => 'Disk',
}
);
open( my $fh, '>', "timeseries.svg" );
select $fh;
binmode $fh;
print $graph->burn();
close($fh);
Venn
#!/usr/bin/perluse warnings;
use Carp;
use strict;
use Venn::Chart;
# Create the Venn::Chart constructor
my $VennChart = new Venn::Chart( 400, 400 ) or die("error : $!");
# Set a title and a legend for our chart
$VennChart->set( -title => 'Venn diagram' );
$VennChart->set_legends( 'Team 1', 'Team 2', 'Team 3' );
# 3 lists for the Venn diagram
my @Team1 = qw/abel edward momo albert jack julien chris/;
my @Team2 = qw/edward isabel antonio delta albert kevin jake/;
my @Team3 = qw/gerald jake kevin lucia john edward/;
# Create a diagram with gd object
my $gd_venn = $VennChart->plot( \@Team1, \@Team2, \@Team3 );
# Create a Venn diagram image in png, gif and jpeg format
open( my $fh_venn, '>', "VennChart.png" );
binmode $fh_venn;
print {$fh_venn} $gd_venn->png;
close($fh_venn);
# Create an histogram image of Venn diagram (png, gif and jpeg format).
my $gd_histogram = $VennChart->plot_histogram;
open( my $fh_histo, '>', "VennHistogram.png" );
binmode $fh_histo;
print {$fh_histo} $gd_histogram->png;
close($fh_histo);
- 使用Perl绘制统计图
- 使用PHP绘制统计图
- 使用PHP绘制统计图
- 使用api绘制统计图
- Delphi如何使用基本的绘图函数绘制统计图
- iOS中使用Core Plot绘制统计图入门
- iOS中使用Core Plot绘制统计图入门
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- iOS中使用Core Plot绘制统计图入门
- Android统计图的绘制( MPChartLib 的使用)
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- 绘制饼形统计图
- C# 绘制统计图
- C# 绘制统计图
- android统计图绘制
- [android] 绘制统计图
- PHP绘制各种统计图
- C#教程笔记
- 新开帐号
- DELPHI加密字串(异或运算加密)
- Entity Framework 5 Sample Provider简介
- FastQ格式介绍
- 使用Perl绘制统计图
- zencart很多资源
- zen cart template zencart模板修改
- 团队项目开发"编码规范"之四:申明
- substr中文乱码问题的解决,使substring函数代替
- zTree v3.2 Demo
- 批量删除一个目录下所有的文件夹和文件
- R语言常用函数
- 批量删除文件