Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

How can I annotate facets that do not have data using ggplot2 facet_grid?

$
0
0

I have multivariate longitudinal samples that I am plotting in a large facet_grid, specifically using facet_grid so that when I don't have a certain time point for a certain sample it still keeps everything in a nicely ordered grid. I am trying to add some sort of indicator to empty facets to show that they don't have data (rather than just having no dots show up), because sometimes the empty facet is a result of not having collected that sample yet. What I have been able to get is a label that shows up in every facet that DOES have data, but I can't seem to figure out how to get a label that shows up in every facet that does NOT have data. It would be even better if I could add a red X through select facets, or some other indication of "No Data Available", rather than a text label, if you have suggestions about that as well.

ggplot(mpg, aes(displ, cty)) + geom_point() + 
facet_grid(vars(drv), vars(cyl)) + geom_text(x = 5, y = 20, label = "Blah")

Example plot


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>