Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ title: Changelog

- Fixed [](:class:`~plotnine.geom_smooth`) / [](:class:`~plotnine.stat_smooth`) when using a linear model via "lm" with weights for the model to do a weighted regression. This bug did not affect the formula API of the linear model. ({{< issue 1005 >}})

- Fixed rendering of SVGs in jupyter notebooks.

## v0.15.2
(2025-12-12)

Expand Down
5 changes: 4 additions & 1 deletion plotnine/_utils/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ def get_mimebundle(
}
mimetype = lookup[format]

image: bytes | str = b
metadata: dict[str, DisplayMetadata] = {}
w, h = figure_size_px
if format in ("png", "jpeg"):
metadata = {mimetype: {"width": w, "height": h}}
elif format == "retina":
# `retina=True` in IPython.display.Image just halves width/height
metadata = {mimetype: {"width": w // 2, "height": h // 2}}
elif format == "svg":
image = b.decode()

return {mimetype: b}, metadata
return {mimetype: image}, metadata
4 changes: 3 additions & 1 deletion plotnine/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@ class DisplayMetadata(TypedDict):
height: NotRequired[int]


MimeBundle: TypeAlias = tuple[dict[str, bytes], dict[str, DisplayMetadata]]
MimeBundle: TypeAlias = tuple[
dict[str, bytes | str], dict[str, DisplayMetadata]
]
Loading