Skip to content

Commit 255a0d1

Browse files
committed
Reduce default plot margins on plotly graphs
1 parent d274322 commit 255a0d1

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ ENV/
108108

109109
js/node_modules
110110
typings/
111-
sandbox/
112111
Untitled*.ipynb
113112

114113
rsconnect-python/

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"editor.formatOnSave": true,
1111
"editor.tabSize": 4,
1212
"editor.codeActionsOnSave": {
13-
"source.organizeImports": true
13+
"source.organizeImports": "explicit"
1414
},
1515
},
1616
"isort.args":["--profile", "black"],

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [UNRELEASED]
99

10+
* Reduce default plot margins on plotly graphs.
1011

1112
## [0.2.4] - 2023-11-20
1213

shinywidgets/_shinywidgets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:
327327
if isinstance(layout, PlotlyLayout):
328328
if layout.height is not None:
329329
fill = False
330+
# Default margins are also way too big
331+
layout.template.layout.margin = dict(l=16, t=32, r=16, b=16)
332+
# Unfortunately, plotly doesn't want to respect the top margin template,
333+
# so change that 60px default to 32px
334+
if layout.margin["t"] == 60:
335+
layout.margin["t"] = 32
330336

331337
widget.layout = layout
332338

@@ -348,7 +354,6 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:
348354
else:
349355
widget.chart = widget.chart.properties(width="container", height="container") # type: ignore
350356

351-
352357
return (widget, fill)
353358

354359
# similar to base::system.file()

0 commit comments

Comments
 (0)