当单独显示时,我可以成功地将带有箭头的 geom_segment 线添加到图中,pl <- ggplot(df.melted, aes(x=energy, y=intensity))pl <- pl + geom_line(aes(color=series))pl &l...
当单独显示时,我可以成功地将带有箭头的 geom_segment 线添加到图中,
pl <- ggplot(df.melted, aes(x=energy, y=intensity))
pl <- pl + geom_line(aes(color=series))
pl <- pl + geom_segment(x=compRange[1], y=2E+10, xend=compRange[2], yend=2E+10, color=gg_color_hue(1), linewidth=0.5, linetype="dashed", arrow=arrow(ends="both", type="closed", length=unit(2, "mm")))
但是,当该图与另一个图一起排列在网格中时,不会显示段线:
ps <- ggplot(dfOrigXRTS, aes(x=energy, y=diff))
ps <- ps + geom_point(color="blue", size=1)
grid.arrange(pl,ps,ncol=1,nrow=2,heights=c(2,1))
R 和软件包的版本如下:R 4.4.0、ggplot2 3.5.1、gridExtra 2.4