Skip to content
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

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

Open
arodionoff opened this issue Aug 11, 2021 · 4 comments

Comments

@arodionoff
Copy link

arodionoff commented Aug 11, 2021

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
Copy link

nefosl commented Jan 29, 2022

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
Copy link

dmoul commented Feb 20, 2023

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
Copy link

heinonmatti commented Mar 10, 2023

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
Copy link

am-lh commented Feb 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants