我正在學習如何使用 R 和 ggplot 庫,并遇到了更改以下直方圖顏色的挑戰!我確實設法從圖表中更改了全色,但它是純色的!我想用不同的顏色進行計數,但不知何故我無法找到正確的方法!你能幫我把它改成另一種顏色嗎?
df4 <- data.frame(rnorm(10000,100,10))
colnames(df4) <- c("Value")
histi_base2 <- ggplot(df4, aes(x=Value))
histi5 <- histi_base2 geom_histogram(binwidth = 1, colour="blue", alpha=0.8, aes(fill=..count..)) labs(title="My first Histogram", subtitle = "in blue")
histi5

uj5u.com熱心網友回復:
嘗試:
df4 <- data.frame(rnorm(10000,100,10))
colnames(df4) <- c("Value")
histi_base2 <- ggplot(df4, aes(x=Value))
histi5 <- histi_base2
geom_histogram(binwidth = 1, alpha=0.8, fill="red", color="black")
labs(title="Your second Histogram", subtitle = "now in solid red")
histi5
隨著fill你改變的酒吧內,用顏色color你改變邊界。

PS:對不起,我認為我沒有正確理解它。Martins 的解決方案似乎更適合。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/381224.html
上一篇:ggplot2根據一個因素設定geom_point大小
下一篇:縱向資料框的呈現,按年份計數
