1

焼却炉の場所を別の区画にプロットしようとしています。

# The first plot
hexbinplot(Easting~Northing | Bclass4, 
    BIRTH_NO68, las=1, scales =list(x = list(log = 10, equispaced.log = FALSE)), 
    aspect = 1, bins=50, style="nested.lattice", 
    main="Spatial distribution of birthweights by quartile")
# The second plot
ppp=xyplot(173098~319444, data=BIRTH_NO68, pch=17, cex=15, col="Black")
# Together
hexbinplot(Easting~Northing | Bclass4, BIRTH_NO68, las=1, 
    scales = list(x = list(log = 10, equispaced.log = FALSE)), aspect = 1, 
    bins=50, style="nested.lattice", 
    main="Spatial distribution of birthweights by quartile") + pop

出てくるのは最初のプロットだけです。これは、焼却炉の場所をマークしようとしている地図です

4

1 に答える 1

1

単一の格子プロットを簡単に組み合わせることができるlatticeExtraas.layerから見てください。で提供されている最初の例に基づくサンプル コードを次に示します。?hexbinplot

library(hexbin)
library(latticeExtra)

## example taken from ?hexbinplot
mixdata <- data.frame(x = c(rnorm(5000),rnorm(5000,4,1.5)),
                      y = c(rnorm(5000),rnorm(5000,2,3)),
                      a = gl(2, 5000))

p1 <- hexbinplot(y ~ x, mixdata, aspect = 1,
                 trans = sqrt, inv = function(x) x^2)

## add points plot to existing hexbinplot
p2 <- xyplot(2.5 ~ 3.5, pch = 24, cex = 3, 
             col = "white", fill = "darkred", lwd = 2)

p1 + as.layer(p2)

ここに画像の説明を入力

内で2 つの異なる関数を定義するだけで、 latticeExtraを使用する必要なく、このタスクを 1 回で実行できることに注意してください。panelhexbinplot

hexbinplot(y ~ x, mixdata, aspect = 1,
                 trans = sqrt, inv = function(x) x^2, 
                 panel = function(...) {
                   panel.hexbinplot(...)
                   panel.xyplot(3.5, 2.5, pch = 24, cex = 3, 
                                col = "white", fill = "darkred")
                 })
于 2016-04-18T14:15:26.233 に答える