0

I am trying to label y-axes using scales="free_y" for facet_wrap. However, every single data point produces a label/tick and it is not scaled properly (see picture). My goal is for the y-axis to be scaled at the individual level for 300+ subplots. FYI, all of my x-axes are the same scale. How can I correct this? I have attempted scales="free" with no success and scales_y_continuous(n.breaks=5) but I get Error in as.vector(x, "character") : cannot coerce type 'closure' to vector of type 'character'.

misscaled y axes

AASWTP0_variation <- ggplot(data=(time_melt), na.rm=TRUE) + 
  geom_point(aes(x=Cycles, y=CPS, col=Sample_replicate)) +
  facet_wrap(~Mass, scales="free_y", ncol=8) + theme_bw() 

ggsave(filename = "AASWTP0_variation_1_60.pdf", plot = 
AASWTP0_variation, device = "pdf", height = 90, width = 50, units = "in", limitsize = FALSE)

Will I need to do something like this: Setting individual axis limits with facet_wrap and scales = "free" in ggplot2

  • 1
    I highly suspect your `CPS` variable is in "character" format instead of "numeric." So ggplot2 is treating each number like a category and listing it specifically instead of placing it on a numeric range. Try `y = as.numeric(CPS)` in your `aes()` – Jon Spring Oct 28 '22 at 23:53
  • You are correct! Such a simple thing (facepalm...it always is). Thank you so much Jon Spring. – symbioticvalgae Oct 30 '22 at 21:20

0 Answers0