GD :: Graph :: lines:如何仅将轴绘制为整数?

时间:2015-02-21 01:53:18

标签: perl graph gd

我正在使用GD::Graph制作图表,并希望y轴显示为整数,而不是小数。轴自动生成基于数据(来自蜂箱下的秤)。我很难过。

这是一个示例图:

enter image description here

我的图表参数是:

 $graph->set(                                           #set the graph parameters
 two_axes        => 2,
 zero_axis       => 0,
 title           => "$hostname $location - $altitude feet elev.      Hive Weight and Temp $weight_filter       $date",
 use_axis        => [1,2,2],
 line_width      => 3,
 x_label         => 'Time',
 x_ticks         => 1,
 x_long_ticks    => 1,
 y_long_ticks    => 1,
 x_tick_number   => $number_of_days+$number_of_days,
 x_number_format => sub { time2str( "%D", $_[0] ) },
 x_label_skip    =>   2,
 y1_label        => 'Weight (Pounds)',
 y2_label        => 'Temperature (Fahrenheit)',
 y1_min_value    =>  int $min_weight,
 y1_max_value    =>  int ($max_weight+1),
 x_min_value     =>  $first_date,
 x_max_value     =>  $last_date,
 y2_min_value    =>  int $min_y2,
 y2_max_value    =>  int ($max_y2+1),
 transparent     => 0,
 boxclr          => 'lgray',

1 个答案:

答案 0 :(得分:0)

您需要调整y_tick_number。但请注意,如果您希望y1y2的刻度都是整数值,那么您需要调整所有内容,以便刻度数均匀地划分两个范围。您可能还想设置y_number_format => '%.0f'以删除整数上的.0