Skip to content

geom_text_repel is not working in plotly while plotting the bubble maps #2386

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

Closed
M-Emran opened this issue Aug 31, 2024 · 2 comments
Closed

Comments

@M-Emran
Copy link

M-Emran commented Aug 31, 2024


geom_text_repel is not working in plotly while plotting the bubble maps provided in the example by plotly: https://plotly.com/ggplot2/bubble-maps/

plot using plotly
Screenshot from 2024-08-31 15 44 17

plot in ggplot2
Screenshot from 2024-08-31 15 44 43

library(plotly)
library(ggplot2)
library(dplyr)
library(maps)
library(ggrepel)

UK <- map_data("world") %>% filter(region=="UK")
data <- world.cities %>% filter(country.etc=="UK")


p <- ggplot() +
  geom_polygon(data = UK, aes(x=long, y = lat, group = group), fill="grey", alpha=0.3) +
  geom_point( data=data, aes(x=long, y=lat, alpha=pop)) +
  geom_text_repel( data=data %>% arrange(pop) %>% tail(10), aes(x=long, y=lat, label=name), size=5) +
  geom_point( data=data %>% arrange(pop) %>% tail(10), aes(x=long, y=lat), color="red", size=3) +
  theme_void() + ylim(50,59) + coord_map() +
  theme(legend.position="none")

ggplotly(p)

p
@trekonom
Copy link
Contributor

trekonom commented Aug 31, 2024

This is essentially a duplicate of #2018 and also the same as #2283 , #2185 and ... . As of the moment geom_text_repel is not supported by plotly and you should get a warning message

geom_GeomTextRepel() has yet to be implemented in plotly.

about that.

But you are right: Having a reference to the non-supported geom_text_repel in an example of the documentation is rather misleading.

@cpsievert
Copy link
Collaborator

Duplicate of #566

@cpsievert cpsievert marked this as a duplicate of #566 Sep 3, 2024
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

3 participants