Skip to content

Commit e76977b

Browse files
committed
Fix dpi so that savefig.dpi doesn't override it
fixes #773
1 parent 1fe90ab commit e76977b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

doc/changelog.qmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ title: Changelog
1616
- Fixed [](:class:`~plotnine.geom_text`) to work better with
1717
[adjustText](https://pypi.org/project/adjustText/) `v1.0.0` and above.
1818

19+
- Fixed images generated in quarto so that they have the dimensions
20+
(taking the dpi into account) that are specified in theme. ({{< issue 773 >}})
21+
1922
### Enhancements
2023

2124
- Added _palmerpenguins_ dataset.

plotnine/iapi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ class mpl_save_view:
170170
figure: Figure
171171
kwargs: dict[str, Any]
172172

173+
def __post_init__(self):
174+
# If savefig.dpi rcparam has been set, it will override
175+
# the figure dpi which is set in the theme. We make sure
176+
# our call to savefig will contain the figure dpi.
177+
if "dpi" not in self.kwargs:
178+
self.kwargs["dpi"] = self.figure.get_dpi()
179+
173180

174181
@dataclass
175182
class layout_details:

0 commit comments

Comments
 (0)