Multiple legends are not independent in their placement and placement is not consistent
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
I am currently experimenting with the new-ish multi-legend feature. Unfortunately I seem to have stumbled across a case in which the legends are not behaving independently even though it is not clear why.
The following code demonstrates this:
from copy import deepcopy
import plotly.graph_objects as go
error_fig = {
'data': [
{
'legend': 'legend2',
'showlegend': True,
'type': 'scatter',
'x': [0, 1],
'xaxis': 'x2',
'y': [0, -1],
'yaxis': 'y2'
},
{
'legend': 'legend3',
'showlegend': True,
'type': 'scatter',
'x': [0, 1],
'xaxis': 'x3',
'y': [0, 1],
'yaxis': 'y3'
},
{
'legend': 'legend3',
'showlegend': True,
'type': 'scatter',
'x': [0, 1],
'xaxis': 'x3',
'y': [0, -1],
'yaxis': 'y3'
},
{
'legend': 'legend3',
'showlegend': True,
'type': 'scatter',
'x': [0, 1],
'xaxis': 'x3',
'y': [0, 1],
'yaxis': 'y3'
},
{
'legend': 'legend3',
'showlegend': True,
'type': 'scatter',
'x': [0, 1],
'xaxis': 'x3',
'y': [0, 1],
'yaxis': 'y3'
}
],
'layout': {
'legend2': {
'orientation': 'v',
'visible': True,
'x': 0.515,
'xanchor': 'left',
'xref': 'paper',
'y': 0.3,
'yanchor': 'top',
'yref': 'paper'
},
'legend3': {
'entrywidth': 0.2,
'entrywidthmode': 'fraction',
'orientation': 'h',
'visible': True,
'x': 0.95,
'xanchor': 'left',
'xref': 'paper',
'y': 1.0,
'yanchor': 'top',
'yref': 'paper'
},
'xaxis2': {'anchor': 'y2', 'domain': [0, 0.5]},
'xaxis3': {'anchor': 'y3', 'domain': [0.45, 0.95]},
'yaxis2': {'anchor': 'x2', 'domain': [0, 0.3]},
'yaxis3': {'anchor': 'x3', 'domain': [0.7, 1.0]}
}
}
correct_fig = deepcopy(error_fig)
correct_fig["layout"]["legend3"]["x"] = 1
fig_correct = go.Figure(correct_fig)
fig_correct.show()
fig_error = go.Figure(error_fig)
fig_error.show()
Where fig_correct produces this output upon png-download (The issue also exists in interactive mode with varying severity based on screen size):
fig_error produces this:
Which for me makes no sense as the only change that occurred was the placement of legend3 along x. I would therefore not expect legend2 to move. Additionally, for me it does not make any sense, why any large movement should occur at all, as I only changed the x-coordinate of legend3 by 0.05 .
For me the Issue only occurs when using "orientation": "h".
I am on Python 3.11.1
My pip dump:
Package Version
---------- -------
packaging 23.1
pip 22.3.1
plotly 5.17.0
setuptools 65.5.0
tenacity 8.2.3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Python reproduction を Plotly 5.17.0 で実行し、interactive mode と PNG output における横方向の multi-legend layout を比較してください。source file や test は指定されていないため、reproduction から legend placement と layout-rendering のエントリポイントをたどってください。legend3 を移動しても、legend2 が予期せず移動したり、不釣り合いな移動が発生したりしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100