4

I noticed that, since ggplot2 released their new version (3.3.0), I can no longer use the package ggtern, as it completely breaks all my plots produced with ggplot2.

library(ggplot2)
df <- data.frame("x" = c(1,2), "y" = c(2,1))
ggplot(df, aes(x,y)) + geom_point()

This produces a normal plot: normal ggplot

However, when i load ggtern, I get the following:

library(ggtern)
ggplot(df, aes(x,y)) + geom_point()

No axes etc.: ggplot after loading ggtern

It also stays this way when i detach ggtern, so I have to restart R to produce normal plots again.

A workaround is to downgrade ggplot2 to an older version (i.e. version 3.2.1), however, this comes with other downsides.

Is there another workaround where I can use the current ggplot2 Version and ggtern?

Servus
  • 373
  • 3
  • 14
  • 1
    I think ggtern is incompatible with the most recent ggplot2 version, there was discussion on ggplot2's github about this: https://github.com/tidyverse/ggplot2/issues/3561#issuecomment-5986825191 – teunbrand Apr 02 '20 at 10:58
  • thank you for the link! hopefully a solution can be found. seems that in the meantime, I will have to stick to ggplot2 version 3.2.1 – Servus Apr 02 '20 at 11:11
  • hey I am on ggtern_3.1.0 ggplot2_3.2.1, don't see this problem – StupidWolf Apr 02 '20 at 13:39
  • That's right, since ggtern overrides ggplot2 functions and ggplot2 has updated it's code, ggtern now breaks ggplot2. ggtern doesn't cause any problems with the older ggplot version. – teunbrand Apr 02 '20 at 16:39
  • 1
    Also seeing this. Opened an issue at the project bitbucket: https://bitbucket.org/nicholasehamilton/ggtern/issues/13/ggtern-breaks-ggplots-plot – Daniel Apr 27 '20 at 12:42
  • In Rstudio having gtern::gtern in a script breaks ggplot, even before running the line. How is that possible? Does Rstudio automatically pre-load packages? – Joost Keuskamp Jun 26 '20 at 12:34

1 Answers1

0

Here is a work-around I found. I save my plot into variable p. Then I call ggplot2:::plot.ggplot(p). That at least makes axis text show up for me.

wdkrnls
  • 4,548
  • 7
  • 36
  • 64