Perl Graph显示的点太靠近轴

时间:2014-10-27 07:15:09

标签: perl graph gd

我正在使用PERL GD :: Graph模块制作一个GUI,其中图形接受来自用户的值。但是,数据点只是在X轴上聚集。这是代码。

#!/usr/local/bin/perl -w
# Change above line to point to your perl binary

use CGI ':standard';
use GD::Graph::points;
use GD::Graph::colour;
use strict;

# Both the arrays should same number of entries.

print "Please enter the number of data-values you have\n";
my $i = <STDIN>;
print "Please enter the gel eletrophoresis values and press enter after each value\n";
my @values;
for ( 1 .. $i ) {
    my $num = <STDIN>;
    chomp $num;
    push @values, $num;
}

my @data = ( [ 0 .. 450 ], [@values] );

my $mygraph = GD::Graph::points->new( 1000, 1000 );
$mygraph->set(
    title           => 'Gel Electrophoresis',
    transparent     => 0,
    bgclr           => 'white',
    dclrs           => [qw(black)],
    #y_tick_number   => 1,                       
    #x_tick_number   => 1,                       
    #no_axes         => 0,                       
    markers         => [9],
    marker_size     => 20,
    accent_treshold => 50,
    #values_vertical => 1,                       
) or warn $mygraph->error;

my $myimage = $mygraph->plot( \@data ) or die $mygraph->error;

print "Content-type: image/png\n\n";
#print $myimage->png;

open IMG, '>file.png';
print IMG $myimage->png;
close IMG;

这是我得到的图表。

enter image description here

如图形图像所示,我在代码中做了哪些更改,以使绘图点不会停留在x轴上并保持在图形上。欢迎提出任何建议。

1 个答案:

答案 0 :(得分:0)

在我看来就像是一个缩放问题。你有......

my @data = ( [ 0 .. 450 ], [@values] );

450范围值应该计算得比你的最高“凝胶电泳”值高一点。使用相同的计算值并添加...

    y_max_value     => $calculated,

...到你的......

$mygraph->set(...);

命令。