1

I am trying create plots of my data where some points are plotted very close to (or on top of) the x-axis. I would like to have the points show up on top of the axis line instead of behind the axis line (see image). ggplot of data with x-axis line over datapoints. Here's the code I have.

`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)')`

I appreciate any advice you can provide.

Benjamin
  • 21
  • 3
  • 1
    Hi Benjamin, welcome to Stack Overflow. You can change the `z` value of the plot panel to be higher than the axis with `grid` similar to [this answer](https://stackoverflow.com/a/40622343/13095326). If you can provide your data with `dput(DataToPlot)`, I can show you specifically. You can edit your question and paste the output. You can surround it with three backticks (```) for better formatting. – Ian Campbell May 13 '20 at 16:14
  • Hi Ian, thanks for the help! The other answer you directed me to had everything I needed! Now it's working great! – Benjamin May 13 '20 at 21:08
  • Glad it worked for you. Cheers – Ian Campbell May 13 '20 at 21:40

0 Answers0