作者:
andrew43 (討厭有好心推文後刪文者)
2025-04-24 16:58:32ggplot 的話,可利用
theme(axis.text.y = element_text(...))
調整 y 軸文字的樣式。
其中,hjust 可調整水平對齊位置。
library(ggplot2)
dat <-
data.frame(Group = c("AAAAA", "B", "CCCCCCCCC"),
Value = c(1, 2, 3))
p <-
ggplot(dat, aes(Value, Group)) +
geom_col()
p + theme(axis.text.y = element_text(hjust = 0)) # 置左
p + theme(axis.text.y = element_text(hjust = 0.5)) # 置中
p + theme(axis.text.y = element_text(hjust = 1)) # 置右
※ 引述《eco100 ( )》之銘言:
: 想問一個geombar設定的問題
: 我想畫橫條的bar圖
: 圖我有畫出來了 但是y軸的分類名稱 卻變成是置中
: 我想把它變成是靠右對齊的話 要使用什麼函數去變更呢?
: google了好久 沒找到 也不知道該用什麼關鍵字比較好?
: 謝謝各位!