3

I have created a code to make a scatter plot combined with a density plot. For several samples, I have set a boundary at some value. The scatter plot (geom_point) does not plot on the left-hand side of the boundary, whereas the density plot (stat_density2d) does plot on the left-hand side of the boundary. How do I override or remove that part (i.e. the shading/alpha on the left-hand side of the boundary, between 1x10E1 and 1x10E2 on the x-axis) of the plot?

Thanks a lot!

visual <- ggplot(data=samples, aes(GRNHLin, REDHLin)) + geom_point(colour='dodgerblue3', size=0.375) +
  stat_density_2d(aes(alpha = ..density..), geom = 'tile', contour = FALSE) +
  scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x),
                labels = trans_format("log10", math_format(10^.x)), limits = c(1,1e4)) +
  scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
                labels = trans_format("log10", math_format(10^.x)), limits = c(1,1e3)) +
  geom_vline(xintercept=40) +
  labs(x="Green Fluorescence", y="Red Fluorescence")
visual

enter image description here

LiWa
  • 51
  • 2
  • Your problem is the shading to the left of the vertical reference line between 1x10E1 and 1x10E2 on the x-axis? – Limey Nov 15 '21 at 12:02
  • Yes, that is issue! I have updated the description of my problem. – LiWa Nov 15 '21 at 12:04
  • What's the thought behind this? @LiWa The density function is using the points for plotting, so there will be always some bleed. I could think of a way via `patchwork` to stich two half plots together... but seriously, why? – Roman Nov 16 '21 at 20:36

0 Answers0