首页 > 解决方案 > 在 x 轴线上方有 ggplot2 geom_points

问题描述

我正在尝试创建我的数据图,其中一些点非常靠近(或在顶部)x 轴绘制。我想让这些点显示在轴线的顶部而不是轴线的后面(见图)。 ggplot 在数据点上具有 x 轴线的数据。 这是我的代码。

`myplot2 = ggplot(DataToPlot, aes(x = H297_B, y = H297_B_Depth))+
  geom_path(size = 1) +
  geom_point(shape = 21, color = 'black', fill = 'blue', size = 3, stroke = 1.5)+
  scale_y_continuous(trans = 'reverse', limits = c(1050, 0)) +
  scale_x_continuous(position = 'top', limits = c(0, 330)) +
  coord_cartesian(clip = 'off', expand = F) +
  theme_classic() +
  theme(text = element_text(size = 14, family = 'Arial'),
   axis.text = element_text(size = 12, family = 'Arial', color = 'black'),
   axis.line = element_line(size = 1),
   axis.ticks = element_line(size = 1, color = 'black'),) +
  labs(x = expression(C-P~Lyase~Activity~(pmol~P~L^{-1}~d^{-1})), y = 'Depth (m)')`

我很感激你能提供的任何建议。

标签: rggplot2

解决方案


推荐阅读