davidhodge931 / ggblanket

Simplify ggplot2 visualisation
https://davidhodge931.github.io/ggblanket/
Other
156 stars 8 forks source link

infinite: gg_* functions do not work if infinite values in variables #143

Closed davidhodge931 closed 1 year ago

davidhodge931 commented 1 year ago
library(ggblanket)
library(tidyverse)

tibble(x = 0:10, y = 1:11) %>% 
  mutate(z = y / x) %>% 
  gg_blank2(x, z, clip = "off") +
  geom_point()

tibble(x = 0:10, y = 1:11) %>% 
  mutate(z = y / x) %>%
  ggplot() +
  geom_point(aes(x, z)) +
  coord_cartesian(clip = "off")

tibble(x = 0:10, y = 1:11) %>% 
  mutate(z = y / x) %>% 
  gg_blank2(x, z, stat = "binhex", clip = "off") +
  geom_hex() 

tibble(x = 0:10, y = 1:11) %>% 
  mutate(z = y / x) %>%
  ggplot() +
  geom_hex(aes(x, z)) +
  coord_cartesian(clip = "off")
davidhodge931 commented 1 year ago

Currently mimicing what ggplot2 does.

But could convert all x/y Infinite values to NA instead??

tibble(x = 0:10, y = 1:11) %>% 
  mutate(z = y / x) %>% 
  mutate(across(everything(), ~na_if(.x, Inf))) %>% 
  gg_blank2(x, z, clip = "off") +
  geom_point()