无法可视化 Chart::Gnuplot 图例中的点

Can't visualize dots in Chart::Gnuplot graph legend

我希望有人能帮我找出在使用 Chart::Gnuplot 模块和 Perl 中的 'dots' 绘制图表时可能出现的问题。

这是我的数据集:

    # RFE Chart object
   my $chart_RFE = Chart::Gnuplot->new(
       output => $out_file_RFE,
       terminal => "png",
       title => {
         text => "Step ROCOF",
         font => "arial, 12",
         },
       xlabel => $chart_xlabel, 
       ylabel => "ROCOF Error (Hz/s)",
       legend => {
         position => "outside top",
         align => "left",
       },
   );

   # RFE Dataset
   $dataSet = Chart::Gnuplot::DataSet->new(
      xdata => \@dataX,
      ydata => \@dataY,
      style => 'dots',
      color => $COLORS[3],
      title=> 'RFE',
   );

我想要点,因为我有很多数据点要绘制图表。但是,它生成的图表的图例在图例名称旁边没有显示任何点。如果我将样式更改为 'points'

style => 'points',

图表的图例中显示了不同的点。有没有办法让点显示?我放大了图例区域,想知道它们是否很小但什么也没有显示。我也尝试过设置 width => 选项,但这没有做任何事情(因为我怀疑它不会因为它用于线条)。

有人知道这是否可能吗?

no option 可以更改图例中的点大小(或 Gnuplot 称之为 "key,"),因此您必须使用 hack 才能达到预期效果。

首先,使用 dots 样式绘制数据集,但不要为其指定标题;然后使用不同的样式绘制一个虚拟数据集并指定一个标题:

use strict;
use warnings;

use Chart::Gnuplot;

my @x = map { rand } 0 .. 10_000;
my @y = map { $_ + 0.1 - rand 0.2 } @x;

my $chart = Chart::Gnuplot->new(
    output  => 'gnuplot.png',
    legend  => {
        position => 'outside top',
        align    => 'left'
    }
);

my $color = '#ff0000';

my $dataset = Chart::Gnuplot::DataSet->new(
    xdata => \@x,
    ydata => \@y,
    style => 'dots',
    color => $color
);

my $dummy = Chart::Gnuplot::DataSet->new(
    ydata     => [ 'inf' ],
    style     => 'points',
    pointtype => 'fill-circle',
    pointsize => 1,
    title     => 'foo',
    color     => $color
);

$chart->plot2d($dataset, $dummy);

输出:

请注意,对于 Gnuplot 的命令行版本,这是 asked elsewhere,但实际上很难创建一个不使用 Chart::Gnuplot 绘制任何内容的虚拟数据集。使用 "inf" 的 y-value 是我唯一不需要知道轴范围的工作。