Skip to content

geom_GeomTextRepel not implemented, no labels on a map #2018

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
danton267 opened this issue Sep 25, 2021 · 1 comment
Closed

geom_GeomTextRepel not implemented, no labels on a map #2018

danton267 opened this issue Sep 25, 2021 · 1 comment

Comments

@danton267
Copy link
Member


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)

The labels are not captured properly. There are supposed to be labels for the 10 largest cities, but no labels are present.

@danton267 danton267 changed the title geom_GeomTextRepel not implemented geom_GeomTextRepel not implemented, no labels on a map Sep 25, 2021
@cpsievert
Copy link
Collaborator

cpsievert commented Nov 2, 2021

I'm not sure it will ever make sense to support conversion of this class of extension (including #2019) because the results change with the size of the R graphics device, and so we'd have to essentially re-implement these extensions client-side for them to work correctly on resize, which would be a very big project.

Ideally, plotly/plotly.js#4674 would get implemented in a way that would support these extensions, but that also seems difficult/unlikely

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

No branches or pull requests

4 participants