在使用PDL :: Graphics :: Gnuplot绘制数据时,我遇到了一个奇怪的效果.看来,一次只绘制有限数量的点replot.
考虑以下示例(15行,101分):
use strict;
use warnings;
use PDL;
use PDL::Graphics::Gnuplot qw/gpwin/;
my $win = gpwin('qt', persist => 1);
foreach my $a (1..15) {
my $x = sequence(101)/100;
my $y = $a*$x;
if ($a == 1) {
$win->plot({ linecolor => 'black' }, $x, $y);
}
else {
$win->replot({ linecolor => 'black' }, $x, $y);
}
}
Run Code Online (Sandbox Code Playgroud)
最后只使用21个点,显示所有15行.
首先,我认为只绘制了有限数量的线,但这不是真的,因为绘制线的数量取决于piddles的大小.
这是perl模块或Gnuplot的限制吗?有没有办法增加最大点数?这似乎是Gnuplots qt版本的问题.使用'x11'as终端不显示此限制(我测试了100行,101点没有任何问题).
此外,我测试相同的例子而不使用replot但是在一个单独的plot.
use strict;
use warnings;
use PDL; …Run Code Online (Sandbox Code Playgroud) 我有一个列表的脚本
@names = ();
@x = ();
Run Code Online (Sandbox Code Playgroud)
两个列表都与数据并行填充,因此,最后我有两个列表,其中包含同一索引中每个元素的名称和x值.注意,有多个元素具有相同的x值.
我希望所有元素都具有特定的x值和代码
foreach my $x (0..4) {
my @ind = grep { $x[$_] == $x } 0..$#names;
print @ind . "\n";
}
Run Code Online (Sandbox Code Playgroud)
但是,输出是
17
17
8
4
Run Code Online (Sandbox Code Playgroud)
这正是x = 0,x = 1,......的元素数量
我想知道因为列表上下文中的grep应该返回一个匹配列表(这里是匹配元素的indizes).
我在这做错了什么?
最好的祝福.