0

我正在使用GD::Graph::lines. 对于选项集,我必须为选项编写固定值,例如x_label => "label"按照以下代码:

my $mygraph = GD::Graph::lines->new($x, $y);
$mygraph->set(
    x_label     => 'label1',
    y_label     => 'label2',
    title       => 'title',

    line_types  => [1, 1, 1, 1],
    line_width  => 2,
) 

有什么方法可以让这些选项像输入变量一样读取$x变量$y

4

1 回答 1

1

只需用这样的变量替换:

my $mygraph = GD::Graph::lines->new($x, $y);
$mygraph->set(
    x_label     => $label_x,
    y_label     => $label_y,
    title       => $title,

    line_types  => [1, 1, 1, 1],
    line_width  => 2,
)
于 2009-09-02T07:01:09.063 回答