Closed jiyunson closed 2 years ago
This might be a bug in xlim. (Seems like a strange bug, so I'm curious to see what I messed up.)
In the meantime, you could try using gf_lims(x = c( ... ))
. That won't be quite the same thing, but in many situations it might be just what you need.
Finally getting around to looking at this. The problem arrises when Inf or -Inf shows up as an endpoint for the range. In that case seq()
can't create a uniform sequence over the range.
This should be fixable.
I have a POC working:
suppressPackageStartupMessages(library(ggformula))
theme_set(theme_bw())
M <- 0
SD <- .026
gf_dist("norm", mean = M, sd = SD) %>%
gf_vline(xintercept = ~(M + 2*SD), color = "blue") %>%
gf_vline(xintercept = ~(M - 2*SD), color = "blue")
gf_dist("norm", mean = M, sd = SD, xlim = c(-0.3, 0.3)) %>%
gf_vline(xintercept = ~ (M + 2*SD), color = "blue") %>%
gf_vline(xintercept = ~ (M - 2*SD), color = "blue")
Created on 2021-06-21 by the reprex package (v0.3.0)
I expect this will be in the next release of the package.
As always, we're super appreciative of all the features of ggformula (and the MOSAIC approach in general)! We're always evangelizing about this package to others who have been teaching R without it. We're huge fans!
We haven't been able to get
gf_dist()
to work as we expect though... for example, this bit of code works as expected:But, if we change mean to -.1 it doesn't work; or if we change xlim to (-.3,.3). Any hints as to how we can understand how this function works better?