问题描述
我正在尝试创建类似
但是我无法获得x和y轴抽动我尝试过类似的操作,以查看x轴运动是否即将到来
But I was not able to get the x and y axis tics coming inI tried something like this to see if the x axis tics are coming
my @data = (
[0, 0, 10],
[0, 1, 10],
[0, 2, 10],
[],
[1, 0, 10],
[1, 1, 5],
[1, 2, 10],
[],
[2, 0, 10],
[2, 1, 1],
[2, 2, 10],
[],
[3, 0, 10],
[3, 1, 0],
[3, 2, 10],
);
my $chart = Chart::Gnuplot->new(
output => "test1.png",
title => "3D plot from arrays of x, y and z coordinates",
xlabel => 'x',
ylabel => 'y',
xtics => {
labels => ['"pi" 3.1416', '"-pi" -3.1416'],
},
);
$chart->set(pm3d => 'map');
$chart->set(palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)');
my $dataSet = Chart::Gnuplot::DataSet->new(
points => \@data,
);
$chart->plot3d($dataSet);
我不确定数据集应该如何以及应该如何添加x和y轴抽动我用从互联网上获得的一些示例测试了上述内容,但看不到结果.任何帮助获得像图像一样的帮助将不胜感激
I am not sure how the dataset should be and how the x and y axis tics should be addedI tested the above with some examples that I got from the internet but was not able to see the result .Any help to get this like the image would be greatly appreciated
还有一个问题,当试图获取X和Y轴上的所有值时,xtics和ytics并未如上图所示充分显示,我得到的似乎是这样的
Got one more issue, when tried to get all the values on X and Y axis, the xtics and ytics are not showing fully as in the above image, the one I got seems like this
数据集是这样的
[
0,
1,
'2.66556908091426'
],
[
0,
2,
'4.37897014657203'
],
[
0,
3,
'1.22514023397498'
],
[
0,
4,
'4.53000730040497'
],
[
0,
5,
'3.01982096624856'
],
[
0,
6,
'0.499618756879272'
],
[
0,
7,
'4.84182728928223'
],
[
0,
8,
'1.96005062661005'
],
[
0,
9,
'2.42800730644825'
],
[
0,
10,
'1.86670807696721'
],
[
0,
11,
'1.81614100038358'
],
[
0,
12,
'4.39616981937487'
],
[
0,
13,
'3.35256272447085'
],
[
0,
14,
'3.24814393010016'
],
[
0,
15,
'1.06219230833835'
],
[
0,
16,
'1.12793288928973'
],
[
0,
17,
'3.26476861756371'
],
[
0,
18,
'3.10578946862982'
],
[
0,
19,
'2.93146341009402'
],
[
0,
20,
'1.72192716962012'
],
[
0,
21,
'4.04316953579938'
],
[
0,
22,
'0.32291976646917'
],
[
0,
23,
'4.42019093014144'
],
[
0,
24,
'3.31129513399691'
],
[
0,
25,
'4.561835018284'
],
[
0,
26,
'1.23709783845847'
],
[
0,
27,
'2.65864379090912'
],
[
0,
28,
'2.30212288203429'
],
[
0,
29,
'0.621743568938786'
],
[
0,
30,
'1.80416068716383'
],
[
0,
31,
'2.66465304546164'
],
[
0,
32,
'3.45680173240485'
],
[
0,
33,
'2.70739617274879'
],
[
0,
34,
'1.11428672300967'
],
[
0,
35,
'1.67761705545201'
],
[
0,
36,
'2.74299975084073'
],
[
0,
37,
'1.80397491377351'
],
[
0,
38,
'4.47728976228916'
],
[
0,
39,
'4.68895286431879'
],
[
0,
40,
'0.14021332300036'
],
[
0,
41,
'2.33736192052044'
],
[
0,
42,
'0.177482592020581'
],
[
0,
43,
'4.73906999291613'
],
[
0,
44,
'2.31796437164231'
],
[
0,
45,
'3.99016409499582'
],
[
0,
46,
'3.38293261332254'
],
[
0,
47,
'2.61350773461833'
],
[
0,
48,
'4.73763682658106'
],
[
0,
49,
'0.882213941365624'
],
[
0,
50,
'0.772076148467349'
],
[
0,
51,
'0.211627911950369'
],
[
0,
52,
'0.983901796963771'
],
[
0,
53,
'4.20512536118553'
],
[
0,
54,
'1.23297443353948'
],
[
0,
55,
'3.81554353946163'
],
[
0,
56,
'3.65498488100304'
],
[
0,
57,
'2.57928958709011'
],
[
0,
58,
'2.59561593117475'
],
[
0,
59,
'0.00576648038274286'
],
[
0,
60,
'3.7901264909274'
],
[
0,
61,
'2.01073954816936'
],
[
0,
62,
'4.20235419868604'
],
[
0,
63,
'0.0699755500835941'
],
[
0,
64,
'1.89704728306967'
],
[
0,
65,
'3.60775496050488'
],
[
0,
66,
'0.210700948492715'
],
[
0,
67,
'1.46456716998541'
],
[
0,
68,
'1.17475107720264'
],
[
0,
69,
'3.05671437798837'
],
[
0,
70,
'2.68927795266336'
],
[
0,
71,
'2.51310517387102'
],
[
0,
72,
'2.47339733795219'
],
[
0,
73,
'0.0279383841017911'
],
[
0,
74,
'0.722901884055389'
],
[
0,
75,
'2.87491127698443'
],
[
0,
76,
'4.06219968687022'
],
[
0,
77,
'1.10014911730135'
],
[
0,
78,
'2.12579086549013'
],
[
0,
79,
'0.969934599414497'
],
[
0,
80,
'0.0104263290325335'
],
[
0,
81,
'4.76235946351673'
],
[
0,
82,
'0.790123228138313'
],
[
0,
83,
'0.0974340515172223'
],
[
0,
84,
'2.25078802534153'
],
[
0,
85,
'1.52078958155231'
],
[
0,
86,
'1.81615557330844'
],
[
0,
87,
'4.29625290304719'
],
[
0,
88,
'3.46711963355933'
],
[
0,
89,
'3.9427030133586'
],
[
0,
90,
'0.10345150062939'
],
[
0,
91,
'3.43953703174092'
],
[
0,
92,
'4.31073758997368'
],
[
0,
93,
'2.58639853373042'
],
[
0,
94,
'4.08224212269872'
],
[],
推荐答案
以下是如何设置轴标签的示例:
Here is an example of how you can set the axis labels:
use strict;
use warnings;
use Chart::Gnuplot;
my @data = (
[0, 0, 10],
[0, 1, 10],
[0, 2, 10],
[0, 3, 10],
[],
[1, 0, 10],
[1, 1, 5],
[1, 2, 10],
[1, 3, 10],
[],
[2, 0, 10],
[2, 1, 1],
[2, 2, 1],
[2, 3, 10],
[],
[3, 0, 10],
[3, 1, 0],
[3, 2, 5],
[3, 3, 10],
);
my $chart = Chart::Gnuplot->new(
bg => 'white',
pm3d => 'map',
palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)',
output => "test.png",
title => "3D plot from arrays of x, y and z coordinates",
xlabel => 'x',
ylabel => 'y',
xtics => {
labels => ['"0030" 0', '"0100" 1', '"0130" 2', '"0200" 3'],
rotate => 90,
},
ytics => {
labels => ['"04-Oct" 0', '"03-Oct" 1', '"02-Oct" 2', '"01-Oct" 3'],
},
);
my $dataSet = Chart::Gnuplot::DataSet->new( points => \@data );
$chart->plot3d($dataSet);
更新:
您可以在这样的循环中创建 xtics
(给定DataTime $ dt
):
You can create the xtics
in a loop like this (given a DataTime $dt
):
my @xtics;
for ( my $i=0; $i<($interval_count-1); $i++ ){
$dt->add(minutes => $interval_period);
my $xtic = '"' . $dt->hour . ':' . $dt->minute . '"' . ' ' . $i;
push @xtics, $xtic;
}
然后将 xtics
参数设置为 Chart :: Gnuplot-> new()
,如下所示:
Then set the xtics
parameter to Chart::Gnuplot->new()
like this:
xtics => { labels => \@xtics, rotate => 90, },
这篇关于使用Chart :: Gnuplot Perl的热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!