【问题标题】:Can't visualize dots in Chart::Gnuplot graph legend无法可视化 Chart::Gnuplot 图图例中的点
【发布时间】:2015-08-03 17:06:39
【问题描述】:

我希望有人可以帮助我找出在使用 Chart::Gnuplot 模块和 Perl 中的“点”绘制图表时出现的问题或可能发生的问题。

这是我的数据集:

    # 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',
   );

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

style => 'points',

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

有人知道这是否可能吗?

【问题讨论】:

  • 点确实出现在图例中,它们只是微不足道的。
  • 您可以使用points 样式、pointtype 7 和小磅值进行绘图。键中的点不受小点大小的影响。

标签: perl charts gnuplot


【解决方案1】:

no option 可以更改图例中的点大小(或 Gnuplot 所称的“键”),因此您必须使用 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 创建一个不绘制任何内容的虚拟数据集。使用 y 值 "inf" 是我唯一不需要知道坐标轴范围的工作。

【讨论】:

  • 这正如你所解释的那样工作。我对你的填充圆点还有另一个问题。你在做什么使它成为一个圆圈?我的 png 以盒子的形式出现,顶部和底部有两条小线。我实际上似乎无法绘制圆点,只能绘制带有线条的框。
  • @TWhite 这由虚拟数据集的参数中的pointtype => 'fill-circle' 控制(pointtype => 7 应该做同样的事情)。 this list of recognized point types 中的任何内容都应该可以工作,尽管我认为您使用的特定驱动程序可能不支持所有这些。检查test 命令的输出,如this post 中所述以确保。
  • 我一直按照你说的设置类型。我不能支持圈子。我可以画三角形、正方形、星形等,但不能画圆形。圆圈出现为带有线条的正方形。 叹气感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-13
相关资源
最近更新 更多