これは私の最初の投稿なので、これを正しく行ったかどうかはわかりません。2 番目の xyplot を plot1 に追加して、バブル プロット (Percent~Distance および Forest_type でグループ化) と同じデータを表すようにしますが、dat$Pixels に基づくバブルのサイズはありません。IE: バブル内のドット。すべてのドットは黒く、非常に小さいはずです。LatticeExtra で as.layer を試しましたが、限られたパネルと機能の経験では動作しませんでした。この元のコードは、はるかに経験豊富な人から入手したもので、わずかに変更することしかできませんでした。提案をありがとう。
library(lattice)
mykey <- list(x = .7, y = .7, corner = c(0,1), text = list(lab = c("D", "C", "M")),
points = list(col = c(2,3,4), pch = 1) )
fontsize <- trellis.par.get("par.main.text")
fontsize$font <- 1
trellis.par.set("par.main.text", fontsize)
trellis.par.get()
plot1<-xyplot(Percent ~ Distance, key = mykey, cex = dat$Pixels / 15000000,
col = dat$Forest_type+1,
xlab="Distance", ylab="Percent of pixels",
data = dat, panel = function(...){
panel.xyplot(...)
})
print(plot1, position=c(0, .5, 1, 1))
再現・使用するデータは以下の通りです。
dat <- structure(list(Pixels = c(51442200L, 16201800L, 9679500L, 8954100L,
4332600L, 4024800L, 2843100L, 2707200L, 2635200L, 1754100L, 1865700L,
1467000L, 1575900L, 1253700L, 1061100L, 1205100L, 1045800L, 909000L,
822600L, 732600L, 837900L, 676800L, 600300L, 538200L, 504900L,
414000L, 316800L, 318600L, 260100L, 261900L, 214200L, 189900L,
182700L, 178200L, 150300L, 135000L, 117000L, 103500L, 90000L,
95400L, 68400L, 79200L, 69300L, 54900L, 72000L, 60300L, 55800L,
41400L, 41400L, 37800L, 24300L, 25200L, 32400L, 36000L, 28800L,
19800L, 18900L, 16200L, 16200L, 60586200L, 25074900L, 18993600L,
21714300L, 13090500L, 13913100L, 10777500L, 11007900L, 11732400L,
8385300L, 9188100L, 7379100L, 8556300L, 7248600L, 6276600L, 7616700L,
6766200L, 6323400L, 5963400L, 5404500L, 6618600L, 5781600L, 5630400L,
5091300L, 5515200L, 4810500L, 4392900L, 4674600L, 4113900L, 4517100L,
3974400L, 3650400L, 3759300L, 3761100L, 3456000L, 3180600L, 2963700L,
2999700L, 2619000L, 2723400L, 2321100L, 2286000L, 2167200L, 1925100L,
1906200L, 1649700L, 1658700L, 1561500L, 1567800L, 1494900L, 1378800L,
1384200L, 1219500L, 1257300L, 1220400L, 1098000L, 1133100L, 959400L,
1044900L, 3713400L, 1295100L, 827100L, 892800L, 549000L, 561600L,
440100L, 432900L, 461700L, 319500L, 344700L, 248400L, 277200L,
221400L, 185400L, 227700L, 222300L, 206100L, 189900L, 177300L,
209700L, 189900L, 170100L, 156600L, 170100L, 163800L, 153900L,
169200L, 148500L, 185400L, 162000L, 165600L, 176400L, 149400L,
128700L, 111600L, 99000L, 83700L, 60300L, 48600L, 32400L, 27000L,
12600L, 6300L, 5400L, 8100L, 9000L, 11700L, 15300L, 16200L, 11700L,
10800L, 6300L, 5400L, 6300L, 9900L, 14400L, 15300L, 15300L),
Forest_type = 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, 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, 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, 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, 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, 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, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L), Distance = c(30L, 60L, 90L, 120L, 150L, 180L, 210L,
240L, 270L, 300L, 330L, 360L, 390L, 420L, 450L, 480L, 510L,
540L, 570L, 600L, 630L, 660L, 690L, 720L, 750L, 780L, 810L,
840L, 870L, 900L, 930L, 960L, 990L, 1020L, 1050L, 1080L,
1110L, 1140L, 1170L, 1200L, 1230L, 1260L, 1290L, 1320L, 1350L,
1380L, 1410L, 1440L, 1470L, 1500L, 1530L, 1560L, 1590L, 1620L,
1650L, 1680L, 1710L, 1740L, 1770L, 30L, 60L, 90L, 120L, 150L,
180L, 210L, 240L, 270L, 300L, 330L, 360L, 390L, 420L, 450L,
480L, 510L, 540L, 570L, 600L, 630L, 660L, 690L, 720L, 750L,
780L, 810L, 840L, 870L, 900L, 930L, 960L, 990L, 1020L, 1050L,
1080L, 1110L, 1140L, 1170L, 1200L, 1230L, 1260L, 1290L, 1320L,
1350L, 1380L, 1410L, 1440L, 1470L, 1500L, 1530L, 1560L, 1590L,
1620L, 1650L, 1680L, 1710L, 1740L, 1770L, 30L, 60L, 90L,
120L, 150L, 180L, 210L, 240L, 270L, 300L, 330L, 360L, 390L,
420L, 450L, 480L, 510L, 540L, 570L, 600L, 630L, 660L, 690L,
720L, 750L, 780L, 810L, 840L, 870L, 900L, 930L, 960L, 990L,
1020L, 1050L, 1080L, 1110L, 1140L, 1170L, 1200L, 1230L, 1260L,
1290L, 1320L, 1350L, 1380L, 1410L, 1440L, 1470L, 1500L, 1530L,
1560L, 1590L, 1620L, 1650L, 1680L, 1710L, 1740L, 1770L),
Percent = c(44.44565403, 38.05758742, 32.81164195, 28.37059427,
24.10736642, 21.75626368, 20.22018818, 19.13486005, 17.77022516,
16.77136219, 16.36794315, 16.1306284, 15.13920111, 14.37119571,
14.10455796, 13.31675783, 13.01669094, 12.22020569, 11.79202684,
11.60205245, 10.92979573, 10.18004603, 9.378515186, 9.301602115,
8.156440826, 7.683313847, 6.51369356, 6.171548117, 5.751243781,
5.275562001, 4.923458833, 4.740507751, 4.436188811, 4.358353511,
4.024096386, 3.93907563, 3.679592414, 3.24767015, 3.249918752,
3.327055869, 2.824228911, 3.31075997, 3.081232493, 2.763932941,
3.629764065, 3.509690938, 3.237597911, 2.564102564, 2.548476454,
2.440441604, 1.717557252, 1.774397972, 2.575107296, 2.772002772,
2.29390681, 1.755786113, 1.62037037, 1.634877384, 1.505016722,
52.34599773, 58.90025792, 64.38464824, 68.80061595, 72.83789874,
75.20797859, 76.64981118, 77.80534351, 79.11634399, 80.17382325,
80.60797473, 81.13805047, 82.1978212, 83.09089033, 83.43103242,
84.16708105, 84.21642209, 85.00907441, 85.48574377, 85.59007982,
86.33482038, 86.96358468, 87.9640045, 87.99191165, 89.09566735,
89.27676633, 90.32198372, 90.55090656, 90.96517413, 90.98984772,
91.35291684, 91.12558976, 91.28059441, 91.98767334, 92.53012048,
92.80462185, 93.20690631, 94.12595312, 94.57263568, 94.97802888,
95.83797845, 95.56057186, 96.35854342, 96.91889443, 96.09800363,
96.01885804, 96.24020888, 96.71125975, 96.50969529, 96.51365485,
97.45547074, 97.46514575, 96.9241774, 96.81219681, 97.20430108,
97.36632083, 97.14506173, 96.82107175, 97.0735786, 3.208348237,
3.042154666, 2.803709805, 2.82878978, 3.054734839, 3.035757723,
3.13000064, 3.059796438, 3.113430843, 3.05481456, 3.024082116,
2.731321128, 2.662977693, 2.537913959, 2.464409618, 2.516161114,
2.766886972, 2.770719903, 2.72222939, 2.807867731, 2.735383893,
2.856369297, 2.657480315, 2.706486234, 2.747891829, 3.039919826,
3.164322724, 3.277545328, 3.28358209, 3.734590283, 3.723624328,
4.133902494, 4.283216783, 3.653973145, 3.445783133, 3.256302521,
3.113501274, 2.62637673, 2.177445564, 1.694915254, 1.337792642,
1.128668172, 0.56022409, 0.317172633, 0.272232305, 0.471451021,
0.522193211, 0.724637681, 0.941828255, 1.045903544, 0.82697201,
0.760456274, 0.500715308, 0.415800416, 0.501792115, 0.877893057,
1.234567901, 1.544050863, 1.421404682), div2erroftot = c(4.966434556,
1.564186201, 0.934497422, 0.864464421, 0.418286433, 0.388570197,
0.27448418, 0.261363854, 0.254412687, 0.169347789, 0.180122097,
0.141630014, 0.152143653, 0.121037184, 0.102442814, 0.116345146,
0.100965691, 0.087758475, 0.079417075, 0.070728117, 0.080894198,
0.065340963, 0.057955349, 0.051959968, 0.048745054, 0.039969206,
0.030585132, 0.030758911, 0.025111088, 0.025284867, 0.02067972,
0.018333701, 0.017638585, 0.017204137, 0.01451056, 0.013033437,
0.011295645, 0.009992302, 0.008688958, 0.009210295, 0.006603608,
0.007646283, 0.006690498, 0.005300264, 0.006951166, 0.005821602,
0.005387154, 0.003996921, 0.003996921, 0.003649362, 0.002346019,
0.002432908, 0.003128025, 0.003475583, 0.002780467, 0.001911571,
0.001824681, 0.001564012, 0.001564012, 5.849232678, 2.42083056,
1.833717675, 2.096384872, 1.263808926, 1.343226002, 1.040502708,
1.062746441, 1.132692552, 0.809550207, 0.887055712, 0.712407658,
0.826059227, 0.699808669, 0.605967924, 0.735346507, 0.653235855,
0.610486182, 0.57573035, 0.521771922, 0.638985964, 0.558178655,
0.543581206, 0.491534348, 0.53245934, 0.4644248, 0.424108035,
0.451304473, 0.397172266, 0.436098797, 0.383704381, 0.352424132,
0.362937771, 0.363111551, 0.333655983, 0.307067772, 0.286127384,
0.289602967, 0.252848675, 0.262927866, 0.224088224, 0.220699531,
0.209230106, 0.185856809, 0.184032128, 0.159268598, 0.160137494,
0.15075342, 0.151361647, 0.144323591, 0.133114835, 0.133636172,
0.11773538, 0.121384742, 0.117822269, 0.106005286, 0.10939398,
0.092624291, 0.100878801, 0.358506403, 0.125034104, 0.079851523,
0.086194462, 0.053002643, 0.054219097, 0.042489004, 0.041793887,
0.044574354, 0.030845801, 0.033278709, 0.023981524, 0.02676199,
0.021374836, 0.017899253, 0.021983063, 0.021461726, 0.019897714,
0.018333701, 0.017117247, 0.020245272, 0.018333701, 0.01642213,
0.015118787, 0.01642213, 0.015813903, 0.014858118, 0.016335241,
0.014336781, 0.017899253, 0.015640124, 0.015987683, 0.017030357,
0.01442367, 0.01242521, 0.010774308, 0.009557854, 0.008080731,
0.005821602, 0.004692037, 0.003128025, 0.002606687, 0.001216454,
0.000608227, 0.000521337, 0.000782006, 0.000868896, 0.001129565,
0.001477123, 0.001564012, 0.001129565, 0.001042675, 0.000608227,
0.000521337, 0.000608227, 0.000955785, 0.001390233, 0.001477123,
0.001477123)), .Names = c("Pixels", "Forest_type", "Distance",
"Percent", "div2erroftot"), class = "data.frame", row.names = c(NA,
-177L))