我想將下圖中的點更改為相應國家/地區的國旗。為此,我知道 geom_flag() 可以作業,但是......不適合我,但我遇到了這個錯誤訊息:
Error in grobify(picture, x = x, y = y, width = width, height = height, :
object '.flaglist' not found
這是我的代碼:
ggplot(df, aes(lenght, Ponto.Caspian))
geom_point() ggflags::geom_flag(aes(x = longitude, y = latitude 0.5, country = country))
也許 geom_image() 也可以作業,但我不知道如何將標志與國家列聯系起來......或者
這是我的資料: https ://drive.google.com/drive/folders/1qR2mUdrpStOYBmxajc_F4nxS_qf-4bzf?usp=sharing
提前致謝
uj5u.com熱心網友回復:
如果我將您的國家/地區轉換為兩個字符的 ISO 代碼(這是https://github.com/jimjam-slam/ggflags上的示例所使用的),這似乎對我有用。
我還必須加載ggflags庫,而不是使用ggflags::geom_flag
例如,使用countrycode包:
df$iso_code <- tolower(countrycode(df$country, origin = 'country.name', destination = 'iso2c'))
ggplot(df, aes(lenght, Ponto.Caspian))
geom_point()
geom_flag(aes(x = longitude, y = latitude 0.5, country = iso_code))
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/437578.html
