閱讀有關序數資料的圖,我發現了
我發現圖例是多余的,因為 10 的小頻率,例如,總是一個小正方形和一個淺正方形,等等。因此,我想用這樣的圖例(油漆解決方案)創建一個情節:

重新創建繪圖的代碼
# DATA
importance <- rep(1:5, times = c(30, 42, 75, 93, 60))
often <- c(rep(1:5, times = c(15, 07, 04, 03, 01)), #n=30, importance 1
rep(1:5, times = c(10, 14, 12, 03, 03)), #n=42, importance 2
rep(1:5, times = c(12, 23, 20, 13, 07)), #n=75, importance 3
rep(1:5, times = c(16, 14, 20, 30, 13)), #n=93, importance 4
rep(1:5, times = c(12, 06, 11, 17, 14))) #n=60, importance 5
running.df <- data.frame(importance, often)
runningcounts.df <- as.data.frame(table(importance, often))
# PLOT
theme_nogrid <- function (base_size = 12, base_family = "") {
theme_bw(base_size = base_size, base_family = base_family) % replace%
theme(panel.grid = element_blank())
}
ggplot(runningcounts.df, aes(importance, often))
geom_point(aes(size = Freq, color = Freq, stat = "identity", position = "identity"), shape = 15)
scale_size_continuous(range = c(3,15))
scale_color_gradient(low = "white", high = "black")
theme_nogrid()
uj5u.com熱心網友回復:
您可以嘗試使用guides,guides(color = guide_legend(), size = guide_legend())在代碼中添加行。
ggplot(runningcounts.df, aes(importance, often))
geom_point(aes(size = Freq, color = Freq, stat = "identity", position = "identity"), shape = 15)
scale_size_continuous(range = c(3,15))
scale_color_gradient(low = "white", high = "black")
guides(color = guide_legend(), size = guide_legend())
theme_nogrid()

uj5u.com熱心網友回復:
如果你想快速修復,這應該有效
# PLOT
theme_nogrid <- function (base_size = 12, base_family = "") {
theme_bw(base_size = base_size, base_family = base_family) % replace%
theme(panel.grid = element_blank())
}
ggplot(runningcounts.df, aes(importance, often))
geom_point(aes(size = Freq, color = Freq, stat = "identity", position = "identity"), shape = 15)
scale_size_continuous(range = c(3,15))
scale_color_gradient(low = "white", high = "black")
theme_nogrid()
guides( colour = guide_legend()) #added guides()

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/375246.html
上一篇:異步函式中的回傳值為空
下一篇:添加標題和第一列
