私が正しくあなたを理解していれば、その後、scale_x_discrete
内expand
引数には何が必要です。あなたはここでそれについての詳細を読むことができます:http://ggplot2.tidyverse.org/reference/scale_discrete.htmlを:
「長さ2の数値ベクトルが与え乗法と加法拡張定数これらの定数は、データが軸からある距離離して配置されていることを確認してください。」
それは形式expand = c(MULTIPLICATIVE_VALUE, ADDITIVE_VALUE)
で使用され、例が以下に提供される:
df <- data.frame(
X = c("v1", "v2", "v3", "v4"),
Y = c(10, 2, 50, 20)
)
# Load Packages
library(ggplot2)
library(gridExtra)
# Build standard plot
plot1 <- ggplot(df, aes(X, Y, fill = X)) +
geom_bar(stat = "identity") +
labs(title = "Standard Plot")
# Add expand argument
plot2 <- plot1 + scale_x_discrete(expand = c(0, 1)) +
labs(title = "Expanded")
# Compare
grid.arrange(plot1, plot2)
再現例とコード? –