Search code examples
rggplot2ggtern

R: ggtern does not work, broken with new ggplot2


I'm trying to use the ggtern package to plot some plots. It used to run on ggplot2, but now it doesn't work and breaks ggplot2.

When I run the following:

library(ggplot2)
qplot(1,2)
library(ggtern)
qplot(3,4)

df = data.frame(x = runif(50),
                y = runif(50),
                z = runif(50),
                Value = runif(50,1,10),
                Group = as.factor(round(runif(50,1,2))))
ggtern(data=df,aes(x,y,z,color=Group)) +
  theme_rgbw() +
  geom_point() + geom_path() +
  labs(x="X",y="Y",z="Z",title="Title")

qplot(1,2) works just fine, library(ggtern) gives me this (which may or may not be related to the problem):

Attaching package: ‘ggtern’

The following objects are masked from ‘package:ggplot2’:

    %+%, %+replace%, aes, calc_element, Geom, geom_segment, ggplot_build,
    ggplot_gtable, ggsave, theme, theme_bw, theme_classic, theme_get, theme_gray,
    theme_grey, theme_minimal, theme_set, theme_update

qplot(3,4) fails with this:

Error in FUN(X[[i]], ...) : attempt to apply non-function

And if I comment it out and it reaches the ggtern(... I get this:

Error in coord_tern() : could not find function "coord"

Obviously, something is wrong. Where do I start looking for what's wrong? What's this function coord and why is it gone?


Solution

  • Yep, ggtern 2.0.1 is now available, published on CRAN a couple of days ago after completely re-writing the package to be compatible withggplot2 2.0.0. A summary of the new functionality in ggtern 2.0.X can be found here:

    Here is what your code produces under the new package:

    solution