plotly / plotly/plotly.py

Problem with radialaxis ticks in polar plot when using date values

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

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

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

Hello, I managed to create a polar heatmap plot following the examples given in #2024, but when trying to use time as the radial dimension I found some problems with the ticks. I tried with tickmodes auto, linear and array but got wrong ticks with all of them. The time values shown in the hover are correct, only the ticks appear to be wrong. Does anyone have a suggestion on what may be the problem?
Thank you.

import numpy as np
import pandas as pd
import plotly.graph_objects as go
from plotly.offline import plot

from datetime import datetime, timedelta

# dt_start, dt_end, dt_step ='2000-01-01', '2001-01-01', '1MS'
dt_start, dt_end, dt_step ='2000-01-01', '2000-01-10', '1D'

times = pd.date_range(dt_start, dt_end, freq=dt_step).values

dirs = np.arange(180, 271, 10)

r, theta = np.meshgrid(times, dirs)

z = np.random.random(r.shape)

hovertemplate = (f'date: %{{r|%Y-%m-%d %H:%M:%SZ}}<br>'
                 f'direction: %{{theta}}<br>'
                 f'value: %{{customdata[0]:.2f}}'
                 '<extra></extra>')

fig = go.Figure(go.Barpolar(r=r.ravel(),
                            theta=theta.ravel(),
                            marker_color=z.ravel(),
                            customdata=np.expand_dims(z.ravel(), 0).T,
                            hovertemplate=hovertemplate))

fig.update_layout(polar=dict(
    angularaxis=dict(tickvals=np.arange(0, 360, 45),
                     direction='clockwise'),
    radialaxis=dict(angle=45,
                    tickangle=45,
                    tickfont={'size': 14},
                    tickformat='%Y-%m-%d %H:%M:%S',

                    # tickmode='auto',
                    # nticks=5,

                    # tickmode='linear',
                    # tick0=times[0],
                    # dtick='1D',

                    tickmode='array',
                    tickvals=times,

                    )))

fig.show()

With tickmode='auto':

tickmode_auto

With tickmode='linear':

tickmode_linear

With tickmode='array':

tickmode_array

Using plotly.version = '5.4.0'

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

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

はじめの一歩

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

調査の方向性

まず、提供された Python の例を Plotly 5.4.0 で実行し、auto、linear、array モードによって生成される radial-axis の目盛りを比較します。日付値を持つ r データについて、radialaxis の目盛り処理を追跡します。3 つすべてのサポート対象モードで、正しく配置され、正しくフォーマットされた日付の目盛りが生成されれば完了です。

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

評価

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

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

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