我可以在 Chart::Gnuplot (Perl) 中填充绘图吗?
Can I pad a plot in Chart::Gnuplot (Perl)?
我正在使用 Chart::Gnuplot 在 Perl 中创建图表。当我在绘图区域的最边缘有数据点时,很难在黑色绘图边框上看到它们:
(你能看到(0,3)和(0,4)边缘的绘图点吗?)
有没有办法用空白填充绘图区域,使图表边缘的绘图点偏离绘图边界?
而不是这个:
----------
| + +
+ |
| + |
----------
...我希望它看起来更像这样:
--------------
| + + |
| + |
| + |
--------------
您可以使用 offsets:
Offsets provide a mechanism to put an empty boundary around the data inside an autoscaled graph. The offsets only affect the x1 and y1 axes, and only in 2D ‘plot‘ commands.
Syntax:
set offsets <left>, <right>, <top>, <bottom>
unset offsets
show offsets
Each offset may be a constant or an expression. Each defaults to 0. By default, the left and right offsets are given in units of the first x axis, the top and bottom offsets in units of the first y axis. Alternatively, you may specify the offsets as a fraction of the total axis range by using the keyword "graph".
以下为每个轴添加 10% 的偏移量:
use strict;
use warnings;
use Chart::Gnuplot;
my @x = (0, 0, 1);
my @y = (3, 4, 10);
my $chart = Chart::Gnuplot->new(
output => 'gnuplot.png',
xrange => [0, 1],
yrange => [0, 10],
offsets => 'graph 0.1, graph 0.1, graph 0.1, graph 0.1'
);
my $dataset = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y
);
$chart->plot2d($dataset);
(Chart::Gnuplot
没有 offsets
选项,但如果您提供它无法识别的选项,它只是 converts it 到 Gnuplot set
声明。)
输出:
我正在使用 Chart::Gnuplot 在 Perl 中创建图表。当我在绘图区域的最边缘有数据点时,很难在黑色绘图边框上看到它们:
(你能看到(0,3)和(0,4)边缘的绘图点吗?)
有没有办法用空白填充绘图区域,使图表边缘的绘图点偏离绘图边界?
而不是这个:
----------
| + +
+ |
| + |
----------
...我希望它看起来更像这样:
--------------
| + + |
| + |
| + |
--------------
您可以使用 offsets:
Offsets provide a mechanism to put an empty boundary around the data inside an autoscaled graph. The offsets only affect the x1 and y1 axes, and only in 2D ‘plot‘ commands.
Syntax:
set offsets <left>, <right>, <top>, <bottom> unset offsets show offsets
Each offset may be a constant or an expression. Each defaults to 0. By default, the left and right offsets are given in units of the first x axis, the top and bottom offsets in units of the first y axis. Alternatively, you may specify the offsets as a fraction of the total axis range by using the keyword "graph".
以下为每个轴添加 10% 的偏移量:
use strict;
use warnings;
use Chart::Gnuplot;
my @x = (0, 0, 1);
my @y = (3, 4, 10);
my $chart = Chart::Gnuplot->new(
output => 'gnuplot.png',
xrange => [0, 1],
yrange => [0, 10],
offsets => 'graph 0.1, graph 0.1, graph 0.1, graph 0.1'
);
my $dataset = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y
);
$chart->plot2d($dataset);
(Chart::Gnuplot
没有 offsets
选项,但如果您提供它无法识别的选项,它只是 converts it 到 Gnuplot set
声明。)