Closing radar chart with plotly go.Scatterpolar

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
plotly, python

調査の方向性

571ページのレーダーチャートの例から始め、Plotly graph-object trace が r と theta の値をどのように提供しているかを調べます。ページをレンダリングして最後の点が最初の点に接続されていないことを確認し、その後、チャートを壊さずにレーダーラインを閉じる解決策を適用して検証します。

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

説明

Hi,

On this page, the radar charts created with plotly graph objects (go.Scatterpolar) do not close — the line connecting the last point back to the first is missing.

Clearly not on you; this is so typical that the official Plotly documentation does it.

The usual line_close=True method from Plotly Express does not work with Graph Objects. And fig.update_traces(connectgaps=True) does not seem to work with radar coordinates.

A possible workaround (mentioned here) is to manually close the loop by repeating the first point in r and theta:

r = df["value"].tolist() + [df["value"][0]]
theta = df["name"].tolist() + [df["name"][0]]

or

r = [*df["value"], df["value"].iloc[0]]
theta = [*df["name"], df["name"].iloc[0]]

It’s stupid, verbose and inelegant, but (on the plus size) it works.

I haven’t made a PR because this might be too niche to implement (after all, the same behavior exists on the official Plotly site), but I can submit one if needed.

PS: I'm bad at it. I might not be aware of a cleaner solution, so there could be a better way.

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

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

holtzy/The-Python-Graph-Gallery のほかの issue

holtzy/The-Python-Graph-Gallery の issue をすべて見る

似ている issue

Data Visualization の issue をもっと見る

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

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