我从模型中绘制了具有PC分数和生存值的三维图形。下图中的颜色代表四种不同的物种。
这是我用来绘制3d图的代码。
library(rgl)
plot3d(x = peryear.lin.q$pc1,
y = peryear.lin.q$pc2,
z = peryear.lin.q$phi,
col=c("#FF3030","#9ACD31", "#1D90FF", "#FF8001")[as.numeric(as.factor(peryear.lin.q$sp))],
xlab = "PC1",
ylab = "PC2",
main = "a plot")
我想知道是否有办法为每组点(因此有4个表面)添加一个只有给定信息的表面。我已经尝试了persp()
,但它需要使用复杂的矩阵结构(带有序列向量)进行插值。此外,image或filled.contour是2D选项,但它不允许我将深度视为3d图。
数据集如下所示:
structure(list(phi = c(0.774548242487706, 0.784045392011979,
0.751678716427871, 0.750115267839873, 0.754245387909098, 0.759284656415386,
0.778790035017713, 0.759668804864664, 0.759489999692065, 0.760601344621595,
0.73418159111732, 0.753220978221876, 0.750716653619977, 0.771208991459769,
0.768647634763075, 0.777356527684307, 0.783849368041401, 0.767578781108701,
0.739583611004977, 0.760787791726833, 0.748297397948902, 0.750756280899325,
0.771240442553501, 0.746584691118004, 0.777619429831833, 0.858391372388783,
0.860868013341423, 0.774043740215855, 0.889333161903512, 0.749487120320738,
0.807568112413955, 0.835414387393067, 0.925245726477432, 0.790564918162702,
0.79359061055276, 0.90101814767841, 0.833466943934336, 0.8352455306306,
0.8102323692874, 0.80244485581586, 0.865537704532203, 0.815061027600176,
0.851544758580267, 0.857776523077353, 0.8629042804338, 0.909862313994888,
0.834073892834433, 0.839862519294067, 0.790281909863798, 0.702076841547232,
0.77160663549605, 0.675305952076373, 0.765718078649449, 0.464453502539252,
0.776813097987235, 0.657209829947235, 0.662118290992857, 0.77383116053607,
0.591457664082092, 0.729653207961127, 0.753066216857122, 0.675639572501431,
0.687817190416591, 0.705639990730532, 0.683881782987352, 0.775062268731872,
0.71538800322388, 0.676083804727636, 0.720888953846423, 0.691740021230329,
0.760511849354045, 0.747940212721768, 0.774917874962645, 0.598209174438799,
0.714405970986909, 0.87931891661762, 0.843234976087422, 0.801611672285703,
0.854621388190757, 0.870412222865092, 0.774554970722778, 0.848644537818176,
0.892859156089765, 0.733509367356896, 0.868259853531807, 0.85722864971942,
0.875234807095326, 0.840804192041962, 0.882355628658944, 0.857178757831746,
0.887327990249508, 0.884389056362009, 0.862922366448537, 0.848385165130717,
0.838424151750123, 0.873021650599649, 0.853418584635651, 0.885936873546461,
0.814335228017734, 0.854883565599494), sp = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L), .Label = c("fortis", "fuliginosa", "magnirostris", "scandens"
), class = "factor"), year = c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), pc1 = c(0.0510649025634495,
-0.0510456130113545, 0.37698991683034, 0.401170393482268, 0.265967115637883,
0.190529701080417, -0.0486659843522206, 0.17687704266941, 0.108698194862257,
0.161433679365801, 0.357770947750688, 0.412280021732771, 0.276298349859949,
0.068567656726962, 0.119248137453797, 0.00585106275846651, -0.00913830630898499,
0.0947363627042171, 0.377411837529966, 0.158485996193305, 0.358732224585638,
0.291316749704137, -0.00267095913428551, 0.349500874927771, 0.00923580311175891,
-0.37016069970886, -0.33940611219255, -0.267640246495039, -0.395726184305461,
-0.309662225953416, -0.28956933555745, -0.360331402784382, -0.278486008950225,
-0.284650498256056, -0.333253905633346, -0.396481596743182, -0.30230601279536,
-0.363916142522096, -0.331956642853948, -0.324794325916332, -0.376469143385632,
-0.349597407002638, -0.338676527653067, -0.400344780850778, -0.282107828412047,
-0.386087348869607, -0.333539793852294, -0.32805434356628, -0.30543532700168,
-0.25763154400952, 0.605911990657696, 0.646265377178229, 0.867751715843845,
0.280993796855893, 0.637436144222113, 0.474009352080523, 0.489145538478489,
0.615102370054689, 0.422503708787374, 0.547721636725492, 0.79475665558955,
0.524307872036318, 0.633088670621309, 0.650621715391557, 0.692132383083277,
0.623411172781876, 0.827732109068878, 0.677749947087509, 0.798000239233322,
0.446363038052123, 0.528566264157602, 0.806962450147393, 0.75983016156671,
0.660293959882232, 0.378247822342847, 0.117271043438555, 0.0682949192970841,
-0.0747413717149509, 0.0111591407256995, 0.0914215590467769,
-0.0940136860881055, 0.0317703731853295, 0.129824283603383, -0.0375327913900695,
0.0464054256527415, 0.0251535245493741, 0.060280211001914, -0.0159277993589392,
0.097160607860465, 0.0602244354274197, 0.129516091483306, 0.0893872062596038,
0.147645425440095, 0.0515103233534877, 0.00718708371839084, 0.0609789140358982,
0.00981703587569432, 0.138589522194252, 0.0284234379094188, 0.0161006533195231
), pc2 = c(0.112205520564287, 0.0396703619928425, -0.0113297561801143,
0.0196517232695751, 0.0180224108050407, 0.182058995280164, -0.0437537238809958,
0.0144117539749174, -0.187091019853636, -0.00748081479687146,
0.385678756959698, -0.0579432603120796, 0.193215618162009, 0.0762093287736741,
0.231649924646305, 0.0442547323660342, 0.142105445908285, 0.0502965477662466,
0.266811108374495, -0.00997154655855628, 0.0931830130589044,
0.133405689572729, -0.0963855269796251, 0.152029644718217, 0.0589969619688447,
0.0637767463933512, 0.00195972959478875, 0.0514999426382286,
0.0208999161838431, 0.225919521455548, 0.0290556176337666, 0.108660664812142,
-0.221545849979698, 0.0517613361529773, 0.159791299483602, -0.0143737304595133,
0.00127279945179946, 0.11886530074707, 0.107598108925214, 0.109955233866079,
0.056117044178477, 0.142503432782114, 0.0219148056681579, 0.145372577345269,
-0.0786602524166752, -0.0566226743198697, 0.0526675304366352,
0.0297371219437, 0.093417135821876, 0.176141825624742, 0.301482696992112,
-0.0417352750618413, 0.250208368869891, -0.304304742313909, 0.292324312508373,
-0.0640246775063241, -0.0582870623871346, 0.294895622878311,
-0.145831333256334, 0.0494872163601558, 0.410389083349893, -0.0412975556039764,
-0.0251914883220257, 0.00196730225434964, -0.0262972621197915,
0.186959839793052, 0.0535487559165496, -0.0382579658626265, 0.476440433790065,
-0.00784998680902625, 0.290779922785293, 0.113213831725062, 0.340208131230503,
0.624365744513008, 0.0573697761617691, -1.0937003981153, -1.16703815471715,
-0.867576681274325, -0.831938503179897, -1.09394723288746, -0.6282894487966,
-0.652596157511586, -0.864274063520554, -0.348794425433301, -0.805495696208592,
-0.758125777618251, -0.88853330467238, -0.857084516851377, -0.790258792783616,
-1.09284241619517, -1.05788789508748, -0.913107163005902, -1.21136111981499,
-1.11348727687724, -1.03868939268555, -0.801430847254626, -0.905624530584372,
-1.0879570943005, -0.487378228261218, -0.93982546391761)), .Names = c("phi",
"sp", "year", "pc1", "pc2"), row.names = c(NA, -100L), vars = list(
sp), drop = TRUE, indices = list(0:24, 25:49, 50:74, 75:99), group_sizes = c(25L,
25L, 25L, 25L), biggest_group_size = 25L, labels = structure(list(
sp = structure(1:4, .Label = c("fortis", "fuliginosa", "magnirostris",
"scandens"), class = "factor")), row.names = c(NA, -4L), class = "data.frame", vars = list(
sp), drop = TRUE, indices = list(0:24, 25:49, 50:74, 75:99), group_sizes = c(25L,
25L, 25L, 25L), biggest_group_size = 25L, labels = structure(list(
sp = structure(1:4, .Label = c("fortis", "fuliginosa", "magnirostris",
"scandens"), class = "factor")), row.names = c(NA, -4L), class = "data.frame", vars = list(
sp), drop = TRUE, .Names = "sp"), .Names = "sp"), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))