我正在 Perl 中使用 Chart::Gnuplot 创建一个图表。当我在绘图区域的最边缘有数据点时,很难在黑色绘图边框上看到它们:
(你能看到边缘上 (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
语句。)
输出:
关于perl - 我可以在 Chart::Gnuplot (Perl) 中填充绘图吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29954085/