将图ggarrange与不同的x轴时间范围对齐

时间:2019-04-30 02:11:20

标签: r ggplot2

我正在ggplotggarrange一起工作。

我有两个不同的时间长度不同的数据集。

我尝试使用align函数无济于事。我如何对齐两个数字?

我尝试将align = "hv"的{​​{1}}使用。

ggarrange
g1<- ggplot(ysi.data, aes(x=timedate, y=Turbid.)) +
  geom_point()

g2<- ggplot(cr300_Wai2, aes(x=timedate, y=Turb_SS)) +
  geom_point()

ggarrange(g1, g2, 
          align = "hv",
          ncol = 1, nrow = 2)

这只是一个片段。关键特征是时间不一致。

图形未对齐,因为structure(list(RECORD = 88002:88007, Temp_C = c(26.12474, 26.12216, 26.11776, 26.11399, 26.11052, 26.10859), Turb_BS = c(65.75296, 65.49622, 64.7587, 64.38072, 66.81303, 66.01526), Turb_SS = c(13.06517, 13.52991, 13.62757, 13.80889, 13.09224, 13.49245), Temp_C_2 = c(26.35429, 26.34946, 26.34464, 26.34039, 26.33621, 26.33335), WD_OBS = c(0L, 0L, 0L, 0L, 0L, 0L), Lvl_m = c(0.5693409, 0.5694, 0.569329, 0.5694232, 0.5691475, 0.569261), timedate = structure(c(1538388300, 1538388600, 1538388900, 1538389200, 1538389500, 1538389800), class = c("POSIXct", "POSIXt"), tzone = "")), row.names = c(NA, 6L), class = "data.frame") structure(list(Date.Time = structure(c(-61575378174, -61575377274, -61575376374, -61575375474, -61575374574, -61575373674), class = c("POSIXct", "POSIXt"), tzone = ""), Temp = c(28.6, 29.21, 29.52, 32.34, 32.92, 33.61), SpCond = c(8L, 7L, 7L, 7L, 6L, 7L), Sal = c(0, 0, 0, 0, 0, 0), DOsat = c(36.2, 23.6, 21.8, 14.7, 10.3, 9.4), DO = c(2.8, 1.81, 1.66, 1.07, 0.74, 0.67), Depth = c(0.303, 0.301, 0.296, 0.297, 0.294, 0.294), Turbid. = c(1, 1.1, 1.1, 2.4, 2.2, 2.2), Battery = c(10.8, 10.8, 10.7, 10.8, 10.8, 10.8)), row.names = c(NA, 6L), class = "data.frame") 数据仅持续到3月,而g2数据持续到4月。

0 个答案:

没有答案