plotly / plotly/plotly.py

constraining axes leads to paper coordinates being off and to extra space between plot area and annotations

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

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

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

説明

If I constrain the x-axis, a legend to the right of the plot area shows up too far to the right and paper coordinates x=0 and x=1 are no longer at the edges of the plot area. Paper coordinate x=1 should always be the right edge of the plot area. There should not be excessive trapped white space between the legend and the plot area. The constrained, no-width behavior should be similar to the unconstrained and constrained-with-width behaviors.

Here I reproduce the problem using the documentation example here:
https://plotly.com/python/axes/#fixed-ratio-axes

I'm happy to provide and diff the output JSON if that would be helpful

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
    x = [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
    y = [0,0,1,1,3,3,2,2,3,3,1,1,0,0],
    name="demo"
))

##Add some elements outside the main plot area
fig.update_layout(
        title=dict(text="Source:  Plotly Bug Report",
                   yref="container",
                   xref="paper",
                   xanchor="right",
                  x=1, y=0.005),
                  showlegend=True
)


#the current layout is reasonable -- the legend is close to the plot area and x=1 in paper coordinates is where we expect it.
fig.show()

#now we constrain the domain and it injects lots of space between the plot area and the legend
#paper coordinates no longer reference the plot area -- paper coordinate x=1 is well to the right of the plot area
fig.update_xaxes(
    range=[-1,4],  # sets the range of xaxis
    constrain="domain",  # meanwhile compresses the xaxis by decreasing its "domain"
)
fig.update_yaxes(
    scaleanchor = "x",
    scaleratio = 1
)

fig.show()

#now we specify the width and the layout becomes reasonable again

fig.update_layout(
    width = 800,
)

fig.show()

unconstrained graphic (expected behavior):
Image
constrained graphic (unexpected behavior)
Image
constrained graphic with width (expected behavior)
Image

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

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

はじめの一歩

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

調査の方向性

リンク先のドキュメントページにある固定比率軸の例から始め、レポートに示されている3つのレイアウトバリエーションを実行します。幅を指定しない制約付きの結果を、制約なしの結果および明示的な幅を指定した結果と比較します。paper x=1 がプロット領域の右端に揃い、プロットと凡例または注釈の間に過剰な空白が残らなければ完了です。

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

評価

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

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

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