1

こんばんは、

複数の密度を 1 つのマップに重ね合わせようとしていますが、1) グループ変数に従って密度 (等高線ではなく) に色を付ける方法がわかりません。2) 最小範囲をキャプチャする方法。

私が見たいのは、マップ全体で透明度が変化するカラフルな密度です。ただし、等高線のみが色を変更します。さらに、一部の地域では大量のデータがあるため、最も低いレベルはまったく強調表示されていません。カウントの代わりに log(count) のようなものとしてビンを分割する方法があるかどうか疑問に思っています。2番目の部分を手動で行うことができると思います。しかし、密度塗りつぶしの色を機能させる方法がわかりません。私のコーディングの試みを以下に示します。本当にありがとうございました。

ggmap(map, extent = "normal", maprange=FALSE) +
stat_density2d(aes(x = longitude, y = latitude, color=as.factor(cluster), alpha=..level..), data=test1, size=1, contour=TRUE)


t2 <- ggmap(map, extent = "normal", maprange=FALSE) %+% test1 + 
aes(x = longitude, y = latitude,  color=as.factor(cluster), fille= as.factor(cluster)) +
  geom_density2d() +
  stat_density2d(aes(fill =as.factor(cluster),  alpha = ..level..), size = 0.001, bins = 200, geom = 'polygon') +
  #scale_fill_descrete(low = "green", high = "red") +
  scale_alpha(range = c(0.000, 0.3), guide = FALSE) +
  coord_map(projection="mercator", xlim=c(attr(map, "bb")$ll.lon,
   attr(map, "bb")$ur.lon), ylim=c(attr(map, "bb")$ll.lat, attr(map, "bb")$ur.lat))

これが私が使用しているデータの例です。ファイル全体を共有することはできません。

  longitude latitude    timestamp mon wday time cluster
1  118.2892 30.15523 1/1/12 19:16   0    0  979       2
2  111.7409 30.78840  1/1/12 9:26   0    0 1569       3
3  111.7409 30.78840  1/1/12 9:23   0    0 1389       1
4  111.7410 30.76408  1/1/12 9:22   0    0 1329       2
5  111.7936 30.81234  1/1/12 9:21   0    0 1269       2
6  111.7908 30.81940  1/1/12 9:20   0    0 1209       4

評判が悪いので画像を投稿できないようですが、あまりきれいではありません。そして、これは私が得る写真です。実際にはマップ全体にデータがあります (および 3 つ以上のグループがありますが、それは重要ではありません)。しかし、カバレッジを増やす唯一の方法は、ビンの数を増やすことです。

4

0 に答える 0