-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gghighlight not working with ggtern #135
Comments
Could you provide a reprex? |
I have subsetted my data (from PSA) as I want to highlight the CoreLocal data only. CoreLocal <- PSA %>% OtherLocal <- PSA %>% ggtern() + |
What is PSA? Could you provide a reprex that I can reproduce on my laptop? |
Sorry, this is the first time I've created a reproducible code, so let me know if it isn't correct. I just want to use gghighlight() to specify a categorical variable rather than a maximum value. library(ggtern) ggtern(data = iris, aes(x=Sepal.Length, y=Sepal.Width, z=Petal.Length, color=Species)) + |
Thanks, really helpful. I could reproduce your example at last! So, this is not that something is wrong with your code. But, I don't understand what's happening here... library(gghighlight)
#> Loading required package: ggplot2
library(ggtern)
#> Registered S3 methods overwritten by 'ggtern':
#> method from
#> +.gg ggplot2
#> grid.draw.ggplot ggplot2
#> plot.ggplot ggplot2
#> print.ggplot ggplot2
#> --
#> Remember to cite, run citation(package = 'ggtern') for further info.
#> --
#>
#> Attaching package: 'ggtern'
#> The following object is masked from 'package:gghighlight':
#>
#> aes
#> The following objects are masked from 'package:ggplot2':
#>
#> %+%, aes, annotate, calc_element, ggplot, ggplot_build,
#> ggplot_gtable, ggplotGrob, ggsave, layer_data, theme, theme_bw,
#> theme_classic, theme_dark, theme_gray, theme_light, theme_linedraw,
#> theme_minimal, theme_void
ggtern(data = iris, aes(x=Sepal.Length, y=Sepal.Width, z=Petal.Length, color=Species)) +
geom_point(size=2) +
geom_mask() +
gghighlight(Species == "setosa")
#> Error: Don't know how to add o to a plot Created on 2020-03-13 by the reprex package (v0.3.0) |
Yeah, that is the exact issue that came up. I didn't know if it was my syntax for gghighlight(), or if it is just not (and has never been) compatible with ggtern()? Is there anything you can do about it from your side? Another option I tried was to subset e.g. 'setosa' and change the shape, colour, and fill. However, this proved to be very difficult as my original dataset needs to specify different shapes for different variables. |
I want to fix gghighlight to compatible with ggtern, but I'm not sure whether it's technically possible or not, at the moment, sorry. |
Okay, thanks for your help anyway! |
Just an fyi, I have tried to use gghighlight() for geom_bar and geom_point. It always come up with: "Error: Don't know how to add o to a plot" I think it is a bug. My R version is Version 1.2.5001 and computer is macOS Version 10.15.1 This is copied code online, which comes up with the error e.g. ` d <- data.frame( p <- ggplot(d, aes(idx, value, colour = cat1)) + p + p + |
Thanks for the notice, but it's not gghighlight's fault, but ggtern's. In the code below, you can see I guess ggtern uses some bad magic here. You already noticed or not, ggtern cannot work with the latest version of ggplot2 (I couldn't even install...). library(ggplot2)
library(gghighlight)
d <- data.frame(
idx = c(1, 2, 3, 4, 1, 2, 3, 4),
value = c(10, 11, 12, 13, 4, 8, 16, 32),
cat1 = rep(c("a", "b"), each = 4),
cat2 = rep(rep(c("1-2", "3-4"), each = 2), 2),
stringsAsFactors = FALSE
)
p <- ggplot(d, aes(idx, value, colour = cat1)) +
geom_line() +
facet_wrap(vars(cat2))
p +
gghighlight(max(value) > 10)
#> Warning: The `...` argument of `group_keys()` is deprecated as of dplyr 1.0.0.
#> Please `group_by()` first
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> label_key: cat1 library(ggtern, warn.conflicts = FALSE, quietly = TRUE)
#> Registered S3 methods overwritten by 'ggtern':
#> method from
#> +.gg ggplot2
#> grid.draw.ggplot ggplot2
#> plot.ggplot ggplot2
#> print.ggplot ggplot2
#> --
#> Remember to cite, run citation(package = 'ggtern') for further info.
#> --
p +
gghighlight(max(value) > 10)
#> Error: Don't know how to add o to a plot Created on 2020-03-13 by the reprex package (v0.3.0) |
It keeps coming up with "Error: Don't know how to add o to a plot" when I try adding gghighlight() to a ternary plot, which has been created using ggtern.
Is this an internal error with the two packages not working together? Or, is it an issue with my code?
The text was updated successfully, but these errors were encountered: