0
私はggplot2ライブラリを使って世界地図を作成しました。ggplot2で世界地図のポイントにラベルを付ける?
私はggplot2でラベルを使用して、それぞれ2つの都市(上海、サンパウロ)の標識しようとしています。ここで
Warning: Ignoring unknown aesthetics: labels
Error: geom_text requires the following missing aesthetics: x, y, label
は完全なコードです:
require(maps)
require(mapdata)
library(ggplot2)
countries = c("Sao Paulo","Shanghai")
global <- map_data("world")
ggplot() + geom_polygon(data = global, aes(x=long, y = lat, group =
group)) +
coord_fixed(1.3)
ggplot() +
geom_polygon(data = global, aes(x=long, y = lat, group = group),
fill = NA, color = "red") +
coord_fixed(1.3)
gg1 <- ggplot() +
geom_polygon(data = global, aes(x=long, y = lat, group = group),
fill = "green", color = "blue") +
coord_fixed(1.3)
gg1
labs <- data.frame(
long = c(-46.625290,121.4580600),
lat = c(-23.533773,31.2222200),
stringsAsFactors = FALSE
)
gg1 +
geom_point(data = labs, aes(x = long, y = lat), color = "red", size
= 5) + ggtitle("World Map") + geom_text(aes(labels=countries),vjust=0,
colour="red")
は明らかに、私はいくつかの方法で間違ったggplotを使用しますが理解することはできませんよ、私はラベルを追加しようとすると、しかし、私は、エラーメッセージが表示されますどうやって?どんな助けもありがとう。