如何在ggplot2中设置y轴和x轴的原点/截取?
x轴的线应该精确到y=Z.
有Z=0或另一个给定的价值.
我有一个dat包含两列 1)Month和 2)的数据框 ( ) Value。我想强调一下,箱线图中的 x 轴不是连续的,方法是用 x 轴上的两条有角度的线(在有角度的线之间是空的)中断 x 轴。
示例数据和箱线图
library(ggplot2)
set.seed(321)
dat <- data.frame(matrix(ncol = 2, nrow = 18))
x <- c("Month", "Value")
colnames(dat) <- x
dat$Month <- rep(c(1,2,3,10,11,12),3)
dat$Value <- rnorm(18,20,2)
ggplot(data = dat, aes(x = factor(Month), y = Value)) +
geom_boxplot() +
labs(x = "Month") +
theme_bw() +
theme(panel.grid = element_blank(),
text = element_text(size = 16),
axis.text.x = element_text(size = 14, color = "black"),
axis.text.y = element_text(size = 14, …Run Code Online (Sandbox Code Playgroud)