這是一個虛構的資料集,展示了我正在使用的內容的總體思路。
Quality <- sample(1:4, 300, replace = TRUE)
reader_ID <- rep(1:3, each = 100)
df <- data.frame(Quality, reader_ID)
df
quality_percentage <- ggplot(df, aes(x = reader_ID, y = Quality, fill = Quality))
geom_bar(position="fill", stat="identity")
quality_percentage
這是它生成的圖表。我試圖將每種品質組合在一起,而不是將它們全部分開。

uj5u.com熱心網友回復:
您可以Quality在繪圖之前簡單地對資料框進行排序:
ggplot(df[order(df$Quality),],
aes(x = reader_ID, y = Quality, fill = Quality))
geom_col(position = "fill")

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/536948.html
標籤:r图表2
上一篇:GGplot列不存在
下一篇:創建具有多個X軸值的圖表
