您好,欢迎来到意榕旅游网。
搜索
您的当前位置:首页使用Perl绘制统计图

使用Perl绘制统计图

来源:意榕旅游网
使用Perl绘制统计图 | Public Library of Bioinformatics

直系同源预测方法现在的位置:󰀁首页󰀁>Script>正文RSS小󰀁中󰀁大使用Perl绘制统计图2011年10月22日󰀁⁄󰀁Script󰀁⁄󰀁暂无评论󰀁⁄󰀁被围观󰀁158󰀁views+Bar代码如下:010203040506070809101112131415161718192021222324252627#!/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);结果图片:第2页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

BarHorizontal

代码如下:

01020304050607080910111213141516171819202122232425

#!/use/bin/perl

use 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);

运行结果:

第3页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

BarLine

代码:

010203040506070809101112131415161718192021222324252627282930313233

#!/use/bin/perl

use 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);

运行结果:

第4页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

LINE

代码:

0102030405060708091011121314151617181920212223242526272829303132333435

#!/use/bin/perl

use 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);

运行结果:

第5页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

Pie

代码:

0102030405060708091011121314151617181920212223242526

#!/use/bin/perl

use 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);

运行结果:

第6页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

TimeSeries

代码:

010203040506070809101112131415161718192021222324252627282930313233343536

#!/use/bin/perl

use SVG::TT::Graph::TimeSeries;

my @data_cpu = (

'2003-09-03 09:30:00', 23, '2003-09-03 09:45:00', , '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;

第7页 共12页2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

37binmode $fh;

38print $graph->burn();39close($fh);

运行结果:

Venn

0102030405060708091011121314151617181920212223242526272829

第8页 共12页

#!/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 formatopen( 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).

2012/2/10 11:01

使用Perl绘制统计图 | Public Library of Bioinformatics

3031323334my $gd_histogram = $VennChart->plot_histogram;open( my $fh_histo, '>', \"VennHistogram.png\" );binmode $fh_histo;print {$fh_histo} $gd_histogram->png;close($fh_histo);运行结果:转载自:Yixf’s󰀁blog:󰀁http://http://yixf.name返回第9页 共12页2012/2/10 11:01

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- yrrf.cn 版权所有 赣ICP备2024042794号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务