5月 30

用R绘制饼图

  • Simple Pie Chart

Script

1
2
3
slices <- c(10, 12,4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
pie(slices, labels = lbls, main="Pie Chart of Countries")

Output
pie1
Continue reading

5月 30

使用Perl绘制统计图

注意:请将代码中的“》”(中文全角)全部替换为“>”(英文半角)。

  • Bar

代码:

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
27
#!/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);

输出:
bar
Continue reading