nicholasehamilton / ggtern

Extension to ggplot2 for plotting ternary diagrams
www.ggtern.com
55 stars 14 forks source link

How should you disable your {ggtern} package to continue using the ggplot2::labs (caption = 'Text') function? #50

Open arodionoff opened 3 years ago

arodionoff commented 3 years ago

How should you disable your {ggtern} package to continue using the ggplot2::labs (caption = 'Text') function?

ggplot2 3.3.5 2021-06-25 [1] CRAN (R 4.0.3) ggtern 3.3.5 2021-07-21 [1] CRAN (R 4.0.3)

# Work
library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(color = class)) +
  geom_smooth(se = FALSE, method = "loess") +
  labs(
    caption = "Data from fueleconomy.gov"
  )

and

# DO NOT Work

library(ggtern)

ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(color = class)) +
  geom_smooth(se = FALSE, method = "loess") +
  labs(
    caption = "Data from fueleconomy.gov"
  )

And the error I get with the code above is:

geom_smooth() using formula 'y ~ x' Error in titleGrob(label, x, y, hjust = hj, vjust = vj, angle = angle, : unused argument (expand_y = TRUE).

nefosl commented 2 years ago

Here's a version that removes the expand_y = TRUE line and runs without error.

It appears that the version of ggtern on cran has much more recent updates than this repo. I forked cran/ggtern and removed expand_y=T from plot-build.R, which fixes this error and hasn't caused any others in my usage.

devtools::install_github("nefosl/ggtern") https://github.com/nefosl/ggtern

dmoul commented 1 year ago

I would much prefer a less drastic solution than forking the package.

I tried following https://stackoverflow.com/questions/46917301/reset-plot-settings-in-r and resetting the theme with theme_set(theme_light()). That didn't work.

I tried unloadNamespace("ggtern"). That didn't work.

I tried unloadNamespace("ggplot2") with the idea I would load it again, however every other package dependent on ggplot2 must be unloaded first. Then loaded again. That's more work than I want to put into this.

Instead I took the path of least resistance and (for now) removed "caption = " from labs().

heinonmatti commented 1 year ago

Just bumped into this at the worst moment -- you know those times when someone wants a plot and the deadline is in 20 minutes. How is this issue still unresolved?

am-lh commented 9 months ago

Hi everyone, The problem is still on, and did not found a solution to this...