legend.maxheight not honored in Jupyter / notebook renderer though works in browser
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
Description
I found that when using legend.maxheight in Plotly (>= 6.3), it works as expected when rendering via browser (e.g. fig.show(renderer="browser") or write_html). However, when using Jupyter Notebook (or similar notebook-based renderers), the maxheight setting is ignored / not reflected — the legend expands or overflows as if maxheight were not applied.
This inconsistent behavior suggests that the notebook renderer is not honoring legend.maxheight, which hampers consistent formatting of legends in notebook environments.
Code Example to Reproduce
import plotly.express as px
from plotly import data
df = data.gapminder().query("year==2007 and continent == 'Europe'")
fig = px.scatter(
df,
x="gdpPercap",
y="lifeExp",
color="country",
size="pop",
size_max=45,
title="Life Expectancy vs. GDP per Capita in 2007 (by Country)",
labels={"gdpPercap": "GDP per Capita"},
)
fig.update_layout(
xaxis=dict(side="top"),
legend=dict(
orientation="h",
yanchor="bottom",
y=-0.35,
xanchor="center",
x=0.5,
maxheight=0.005, # comment out this line to see legend take up ~0.5 of plotting area
title_text="Country"
),
)
# Display inline in notebook
fig.show()
# Display via browser
fig.show(renderer="browser")
When executed:
- In browser renderer, the legend is constrained in height per the
maxheight=0.005setting (i.e. 0.5% of plotting height). - In notebook renderer, the legend is not constrained and expands beyond that, ignoring the
maxheight.
Expected Behavior
The legend.maxheight setting should be honored consistently across all renderers, including the notebook-based inline renderers inside Jupyter or related environments. That is, legends should be constrained to the height specified by maxheight, even when showing inline.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている Plotly Express の例を Jupyter notebook で fig.show() を使って実行し、fig.show(renderer="browser") でも実行して、write_html と凡例の動作を比較します。notebook ベースの renderer のエントリーポイントを追跡し、legend.maxheight が適用されない理由を特定します。完了とは、notebook の renderer がブラウザーの renderer と一貫して凡例を制約することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- jupyter-notebook, python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100