You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require(ggplot2)
require(ggtern)
df <- data.frame(
x = c(1,7,5),
y = c(7,2,6),
z = c(1,1,7)
)
ggtern(data = df, aes(x=x, y=y, z=z)) +
geom_point()
produces:
As soon as I add cowplot, I get an error. This code:
require(ggplot2)
require(ggtern)
require(cowplot)
df <- data.frame(
x = c(1,7,5),
y = c(7,2,6),
z = c(1,1,7)
)
ggtern(data = df, aes(x=x, y=y, z=z)) +
geom_point()
Produces the error:
Error in if (zero_range(as.numeric(limits))) { :
missing value where TRUE/FALSE needed
In addition: Warning message:
In if (x) { : argument is of length zero
I can't properly debug this at this time because ggtern does not seem to work with the current development version of ggplot2. In either case, it looks like the cowplot theme is at fault. ggtern adds a lot of elements to the theme and cowplot doesn't know that. There should be two workarounds:
Try theme_set(theme_gray()) after loading cowplot and see if that fixes things.
Don't load cowplot at all, just call its functions via cowplot::..., e.g. cowplot::plot_grid().
Anyway, thanks for taking the time to help. The first workaround will do what I want for the moment. It would be nice to be able to use plot_grid() with ternary plots in the future, but I understand that maybe it wouldn't be such a widely used feature...
The problem is that ggtern replaces all the default ggplot2 functions and cowplot doesn't know that and continues to call the functions from the ggplot2 namespace, not the ggtern one. There isn't a good way to fix this, because ggplot2 was not written for what ggtern does to it.
Reacted by Zhi Yang, Jeremy, David Firth and Mirek Kratochvil
Activity
clauswilke commentedon Feb 14, 2018
Please provide a minimal reproducible example.
Fitzgabbro commentedon Feb 15, 2018
Sorry, here's a minimal working example:
produces:

As soon as I add cowplot, I get an error. This code:
Produces the error:
clauswilke commentedon Feb 15, 2018
I can't properly debug this at this time because ggtern does not seem to work with the current development version of ggplot2. In either case, it looks like the cowplot theme is at fault. ggtern adds a lot of elements to the theme and cowplot doesn't know that. There should be two workarounds:
Try
theme_set(theme_gray())after loading cowplot and see if that fixes things.Don't load cowplot at all, just call its functions via
cowplot::..., e.g.cowplot::plot_grid().Fitzgabbro commentedon Feb 15, 2018
Using
theme_set(theme_gray())works perfectly with one ternary plot.Using
plot_grid()sort of works, but the axes go a bit funny (both if I call it usingcowplot::, or if I usetheme_set(theme_gray()). For exampleproduces this figure:

Anyway, thanks for taking the time to help. The first workaround will do what I want for the moment. It would be nice to be able to use
plot_grid()with ternary plots in the future, but I understand that maybe it wouldn't be such a widely used feature...clauswilke commentedon Feb 15, 2018
Try the following:
The problem is that ggtern replaces all the default ggplot2 functions and cowplot doesn't know that and continues to call the functions from the ggplot2 namespace, not the ggtern one. There isn't a good way to fix this, because ggplot2 was not written for what ggtern does to it.