2

I am looking to add an additional white line to the background grid and a additional tick mark, but only within the facet Low Tide, is that in any way possible?

I imagine i would be possible to add a break (at y = 10) to the scale_y_continuous() command within Low Tide or something similar (please see below for code).

_break_ to the <code>scale_y_continuous()</code>

require(ggplot2)
df <- data.frame(cyl = mtcars[,2])
df$Tide  <- ifelse(df$cyl > 4, c('High Tide'), c('Low Tide'))
c <- ggplot(df, aes(factor(cyl)))
c + geom_bar(fill="white", colour="darkgreen", alpha=0.5) +
       facet_grid(. ~ Tide, scales = "free", space = "free") +
       scale_y_continuous(breaks=c(4, 6, 8),
          labels=c("Minimal", "Mild", "Moderate")) +
       scale_x_discrete(breaks=c(6,8,4),
          labels=c("East Coast", "West Coast", "West Coast Summer")) + 
       theme(axis.title.x = element_blank(), axis.title.y  = element_blank(), 
          axis.ticks.x = element_blank(), legend.position = "none") 
Eric Fail
  • 8,191
  • 8
  • 72
  • 128
  • 1
    I've learnt that anything is possible with R, but I don't know how to do this. However, a workaround would be to use `annotate()` to put a label in the low tide facet. – Andrie Jan 30 '13 at 06:41
  • The answer is NO I think. In this case, you should plot them as separate plots and print them with 2 columns, for example, maybe with [**gridExtra**](http://stackoverflow.com/questions/6681145/how-can-i-arrange-an-arbitrary-number-of-ggplots-using-grid-arrange) – Arun Jan 30 '13 at 07:04
  • Broken axes are frowned upon and should not be used. Hence, they are not implemented in ggplot2. You may get away with them in base graphics, though. – Roman Luštrik Jan 30 '13 at 07:06
  • @RomanLuštrik, I am not looking to break any axes, I simply want to emphasize the level "Severe" (at y = 10) on the _Low Tide_-facet. – Eric Fail Jan 30 '13 at 07:22
  • 1
    Is it me or is there no `severe` in this plot? Also, your question asks, *introducing a break within a facet* `Low tide` and that's what @RomanLuštrik explained as breaking the axes. – Arun Jan 30 '13 at 07:27
  • If I have misunderstood your question I apologize. – Roman Luštrik Jan 30 '13 at 07:37
  • @arun, I am sorry about the unclear language. I am asking to add a break to the `scale_y_continuous()` command that creats the white lines and the tickt texts. No, there is no 'Severe' level in the data. I simply added that in an attempt to explain why I want an additional line at y = 10. Does this make sense? I'll try to update my question ASAP. Feel free to suggest edits that you think would clarify what I am looking to do. – Eric Fail Jan 30 '13 at 07:44
  • @RomanLuštrik, my convoluted wording didn't made it any easier. I appreciate your feedback! – Eric Fail Jan 30 '13 at 07:49

0 Answers0