我在 ggplot2 中使用這個想法時遇到了麻煩
axis(1, at=1:6, lab=c("Art", "Basic", "Comp", "Day", "Est", "Fin"))
我怎么能用 ggplot2 包做到這一點?謝謝!
uj5u.com熱心網友回復:
您確實需要向我們展示您的其余資料和繪圖代碼才能在此處獲得完整答案,但示例如下:
library(ggplot2)
df <- data.frame(x = 1:6, y = c(5, 2, 3, 4, 6, 1))
ggplot(df, aes(x, y))
geom_point()
scale_x_continuous(breaks = 1:6,
labels = c("Art", "Basic", "Comp", "Day", "Est", "Fin"))

根據您正在繪制的內容,您甚至可能不必這樣做。例如,如果您的資料是:
df <- data.frame(x = c("Art", "Basic", "Comp", "Day", "Est", "Fin"),
y = c(5, 2, 3, 4, 6, 1))
然后你可以這樣做,例如:
ggplot(df, aes(x, y)) geom_col()

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/450633.html
上一篇:說明直方圖中的標準偏差
