Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df823b4

Browse files
committed
Copy width/height calculating logic from kaleido
1 parent 3d36c65 commit df823b4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎plotly/io/_kaleido.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,26 @@ def to_image(
376376
if defaults.mathjax:
377377
kopts["mathjax"] = defaults.mathjax
378378

379-
# TODO: Refactor to make it possible to use a shared Kaleido instance here
379+
380+
width = (
381+
width
382+
or fig_dict.get("layout").get("width")
383+
or fig_dict.get("layout").get("template", {}).get("layout", {}).get("width")
384+
or defaults.default_width
385+
)
386+
height = (
387+
height
388+
or fig_dict.get("layout").get("height")
389+
or fig_dict.get("layout").get("template", {}).get("layout", {}).get("height")
390+
or defaults.default_height
391+
)
392+
380393
img_bytes = kaleido.calc_fig_sync(
381394
fig_dict,
382395
opts=dict(
383396
format=format or defaults.default_format,
384-
width=widthordefaults.default_width,
385-
height=heightordefaults.default_height,
397+
width=width,
398+
height=height,
386399
scale=scale or defaults.default_scale,
387400
),
388401
topojson=defaults.topojson,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /