Skip to content

Aspect ratio of geom_map is distorted after conversion to plotly #1797

@kato-m

Description

@kato-m

Disclaimer: This is a x-post from stackoverflow, but the longer I ponder around this issue, the more I think, this might be a bug.

I am trying to create an interactive map of Germany with plotly and ggplot. At last, I'd like to overlay geom_points with tooltips, but so far I am struggeling with the aspect ratio.

I create the plot like this:

library(tidyverse)
library(ggplot2)
library(plotly)

p <- map_data("world") %>%
  filter(region=="Germany") %>%
  ggplot(aes(x=long, y = lat, group = group)) +
  geom_polygon(fill="grey") +
  coord_map()

When simply plotting it with ggplot, the aspect ratio of Germany is how I know it from school.

p

germany_with_correct_aspect_ration

When converting it to a plotly plot with ggplotly the plot is distorted.

ggplotly(p)

enter image description here

Any ideas how to fix it? I don't know whether this is relevant, but I used to run this code in an R Markdown document.

Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions