我有以下代码:
values <-as.numeric(logb["apple",])
这是打印出的值(dput(values))
c(10.2082514459856, 10.4902973823758, 9.47768668408161, 11.3723768477379,
9.77536684750538, -9.96578428466209, 9.84730063667018, -9.96578428466209,
-9.96578428466209, 9.67701163699829, 8.89308833957647, -9.96578428466209,
-9.96578428466209, -9.96578428466209, 4.88074953878337, 10.8377700714459,
9.67240471248415, 11.5511326468668, 12.2959711912287, 11.177615795467,
1.27119342003884, 5.89488205689347, 11.0431443899632, 11.5195630239185,
8.88611025224185, 0.415935433860163, 10.0909201197081, 1.11935341546107,
2.29304065399253, 6.44051757029159, 7.27223875130745, 4.17286046030363,
12.2959711912287, 8.93756225545764, -9.96578428466209, 2.82374113821326,
-9.96578428466209, -9.96578428466209, 6.7845186590085, 6.75725140640872,
3.30799054888394, 1.33285051619047, 11.101382871803, 9.56310340687048,
6.05138486988801, 11.1647849791133, 0.641635397441647, 2.25818627743786,
6.84610893026537, 0.901701555037384, 5.03961679294633, 8.06503754820301,
1.91447713578233, 1.9928923747979, 10.0568354293295, 4.18387614879524,
1.44569558279273, 9.44208535287348, 10.7610369594203, 10.072507716131,
5.65824078415041, 11.4459048182974, 4.98525549087584, 9.27145968612689,
4.62079777510227, -9.96578428466209, -0.158667210269291, 7.84066444448994,
10.6469170548272, 8.10132712431389, 10.4213033125177, 7.63017723790216,
9.81489035782327, 10.4460595786456, 7.61256542193715, 10.5929209140244,
10.6811542795194, 8.63528904198814, 7.08127496996433, 9.37016682222762,
9.72611927800663, 8.79221371065147, 11.3773355782529, 10.1340953557389,
8.54228484219991, 9.19473410925412, 9.22357213395061, -9.96578428466209,
2.06859466822583, 7.85102679919433, 10.2163208336518, 7.32085556502439,
7.17868854717394, 7.29012837656103, 9.39064690437556, 11.2182673550456,
0.99311790454659, 10.7368071623741, -1.27079596440878, 1.56468983173253,
-1.53765829204471, 1.52571260435293, 7.59811777053149, 11.2580431640925,
5.76919580165809, 1.46352533364979, 10.6689743752467, -0.193965895767357,
-9.96578428466209, -0.109202767044596, 10.2737478964469, 1.86021230860232,
0.0522958052916171, 9.1092758724906, 6.75497051676772, -9.96578428466209,
7.37624441532334, -1.18384163060835, 10.0953264750968, 10.6621044264772,
0.978455308901519, -0.587808292937742, 1.70242105031789, 7.11891286936701,
-1.00259671835003, -9.96578428466209, 3.44482984576332, 3.66543195857478,
2.30526333330383, 9.25052251950323, 0.476030098407833, 0.677679180622868,
0.534955605208228, -9.96578428466209, -0.256817262299128, -0.885928458985493,
12.2814393400001, 11.4863572973797, 1.57340309064393, 1.81157359280116,
5.2245285179973, 2.82243460348834, 2.63202604954669, 10.9667282364522,
11.3976633449755, 6.32855877090442, 3.35147802913235, 1.85503402661645,
11.0716881588527, 0.628046239188407, 1.26195497683904, 1.84045926703231,
2.36940605873192, 10.7242992203832, 9.033707994836, 0.174047497925867,
0.355836934605625, 0.0160116696602818, 8.74355131463472, 10.5306121395554,
-1.02983443236526, -9.96578428466209, 11.0009715331005, 2.29188360496881,
4.60733173639137, 0.720275634705577, 1.33766127191757, -1.02773392506387
)
然后我绘制值,沿着色谱从最小到最大着色点:
maxColorValue <- 20
my_palette <- colorRampPalette(c(brewer.pal(11,"Spectral")))(maxColorValue)
value <- values(dcor, pch=19,col = my_palette[cut(values, maxColorValue),])
结果图是正确的。我只是不确定如何绘制传奇?据推测这是可能的。 谢谢