`object not found` if `gghighlight` doesn't directly follow `geom_line`
nrjones8 opened this issue · comments
Hi! First of all, thanks for making this package, it's super useful.
I ran into an issue when trying to include a geom_hline
on the same graphic as one that used gghighlight
. What I found was that gghighlight
had to immediately follow the call to geom_line
. To demonstrate:
library(gghighlight)
library(ggplot)
# this works:
g <- ggplot(mtcars) +
geom_line(aes(drat, wt, color=as.factor(gear))) +
gghighlight(max(wt) > 3)
geom_hline(yintercept=3)
print(g)
# if we switch the order and draw the `geom_hline` first, we get an error like so:
# Error in mutate_impl(.data, dots) : Evaluation error: object 'wt' not found.
g <- ggplot(mtcars) +
geom_line(aes(drat, wt, color=as.factor(gear))) +
geom_hline(yintercept=3) +
gghighlight(max(wt) > 3)
print(g)
Let me know if you need any more detail, thanks!
Thanks for reporting, this is a bug and was fixed by #78. Could you consider using the dev version for now?
Thanks for the quick follow-up, can definitely use dev for now!