plotly / plotly/plotly.R

Aspect ratio of geom_map is distorted after conversion to plotly

Ouverte
#1,797 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par l’exemple R utilisant map_data("world"), geom_polygon(), coord_map() et ggplotly() afin de reproduire la carte déformée de l’Allemagne. Comparez la sortie statique de ggplot avec le graphique interactif converti et examinez comment les paramètres de coordonnées sont transférés. Le travail est considéré comme terminé lorsque le résultat interactif préserve le rapport hauteur/largeur d’origine tout en prenant en charge la superposition et les info-bulles prévues.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
plotly, r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.