我的問題是,對于 ggplot,當 x 軸包含日期時,左側的圖中給出了過多的多余空間
是否有可能洗掉紅色空間?使整個曲線和 x 軸向左移動。
library(tidyverse)
set.seed(138)
mydat <- (as.Date("2021-04-01") 0:99) %>% as.data.frame()
y <- rnorm(100)
mydat$val <- y
names(mydat) <- c("Time", "Value")
ggplot(mydat, aes(x=as.Date(Time))) geom_line(aes(y=Value))
scale_x_date(breaks = c(seq(as.Date('2021-04-01'), as.Date('2021-08-01'), by="2 week")) , date_labels = "%d-%b-%y ", limits=c(as.Date('2021-04-01'), as.Date('2021-07-09'))) theme(legend.position="bottom")
theme(
axis.text.x = element_text(angle=45,size=10, vjust = 0.5))

uj5u.com熱心網友回復:
將expand =c(0,0)引數添加到scale_x_date

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/477551.html
