我正在使用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
是输入变量?
答案 0 :(得分: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,
)