plotly / plotly/plotly.R

Aspect ratio of geom_map is distorted after conversion to plotly

オープン
#1,797 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

map_data("world")、geom_polygon()、coord_map()、ggplotly()を使用するRの例から始め、歪んだドイツの地図を再現します。静的なggplotの出力と変換後のインタラクティブなプロットを比較し、座標設定がどのように引き継がれるかを調査します。インタラクティブな結果が元のアスペクト比を維持しながら、意図したオーバーレイとツールチップを引き続きサポートできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
plotly, r
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。