njtierney/naniar

geom_missing_point renders points cropped by plot limits as 'Missing'

Offen

#58 geöffnet am 15.06.2017

 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)R (56 Forks)batch import
bugenhancementhelp wanted

Repository-Metriken

Stars
 (674 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

@karawoo's response to my ggplot2 issue on missing data warnings made me twig this behaviour could also be an issue for geom_missing_point. It turns out that converting data outside the plot limits to NA seems to happen before our overloaded setup_data...(wat) creating a potentially misleading plot:

library(narnia)
library(ggplot2)
df <- data.frame(x = c(1:5) , y = 1:5)

ggplot(df, aes(x = x, y = y)) + 
  geom_missing_point() +
  xlim(c(0,4)) +
  ylim(c(0,5))

Her proposed work around using coord_cartesian does avoid the incorrect point categorisation:

ggplot(df, aes(x = x, y = y)) +                
geom_missing_point() +                         
coord_cartesian(xlim = c(0, 4), ylim = c(0, 5))

Contributor Guide