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

ggplot2 3.5.0 problem with legend.position.inside #5766

Closed
amarjitsinghchandhial opened this issue Mar 11, 2024 · 2 comments · Fixed by #5767
Closed

ggplot2 3.5.0 problem with legend.position.inside #5766

amarjitsinghchandhial opened this issue Mar 11, 2024 · 2 comments · Fixed by #5767

Comments

@amarjitsinghchandhial
Copy link

I have found a problem with legend.position.inside.

The following is based from the reference manual p.303-p.304:

library(ggplot2)

p2 <- ggplot(mtcars, aes(wt, mpg)) +
 geom_point(aes(colour = factor(cyl), shape = factor(vs))) +
 labs(
   x = "Weight (1000 lbs)",
   y = "Fuel economy (mpg)",
   colour = "Cylinders",
   shape = "Transmission"
 )
p2


# Position
p2 + theme(legend.position =  c(.94, .75)) # inside

# Warning message:
# A numeric `legend.position` argument in `theme()` was deprecated in ggplot2 3.5.0.
# ℹ Please use the `legend.position.inside` argument of `theme()` instead.
# This warning is displayed once every 8 hours.
# Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.


p2 + theme(legend.position.inside =  c(.94, .75)) # outside

Please can you resolve.

thanks,
Amarjit

@teunbrand
Copy link
Collaborator

This seems like an example in the theme() documentation needs an update.

@amarjitsinghchandhial
Copy link
Author

I have seen https://github.com/tidyverse/ggplot2/releases

and

p2 + theme(legend.position = "inside", legend.position.inside = c(.94, .75))

is correct.

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

Successfully merging a pull request may close this issue.

2 participants