Themes¶
Theme Elements¶
element_markdown¶
- class plotnine_extra.element_markdown(family=None, style=None, weight=None, color=None, size=None, ha=None, va=None, rotation=None, linespacing=None, backgroundcolor=None, margin=None, face=None, **kwargs)[source]¶
Bases:
plotnine.element_textTheme element for rendering text with markdown-style parameters
A convenience wrapper around
element_textthat accepts extra styling shortcuts inspired by R’sggtext::element_markdown.- Parameters:
family (str) – Font family.
style (str) – Font style (
"normal","italic").size (float) – Font size.
ha (str) – Horizontal alignment.
va (str) – Vertical alignment.
rotation (float) – Rotation angle in degrees.
linespacing (float) – Line spacing multiplier.
backgroundcolor (str | tuple) – Background colour behind the text.
margin (dict | Margin) – Margin around the text.
face (str) – Convenience shortcut:
"bold","italic","bold.italic", or"plain".**kwargs – Extra matplotlib text properties.
Notes
R’s
element_markdowncan render arbitrary inline HTML/CSS inside plot titles and labels. matplotlib does not support this; only whole-element properties (colour, weight, style, background) are available.
element_textbox_simple¶
- class plotnine_extra.element_textbox_simple(family=None, style=None, weight=None, color=None, size=None, ha='left', va='top', linespacing=1.2, backgroundcolor=None, margin=None, face=None, **kwargs)[source]¶
Bases:
plotnine.element_textTheme element for text rendered inside a box
A convenience wrapper that sets sensible defaults for boxed text (transparent fill, no border, full width). Inspired by R’s
ggtext::element_textbox_simple.- Parameters:
family (str) – Font family.
style (str) – Font style.
size (float) – Font size.
ha (str) – Horizontal alignment.
va (str) – Vertical alignment.
linespacing (float) – Line spacing (default
1.2).margin (dict | Margin) – Margin around the text.
face (str) – Convenience shortcut:
"bold","italic","bold.italic", or"plain".**kwargs – Extra matplotlib text properties.
Notes
In R,
element_textbox_simplerenders a word-wrapped text box. In plotnine, word wrapping must be done at the data level (e.g. withtextwrap.fill). This element applies the visual styling.
Publication Themes¶
theme_pubr¶
- class plotnine_extra.theme_pubr(base_size=12, base_family='')[source]¶
Bases:
plotnine.theme_bwPublication-ready theme inspired by ggpubr.
A clean theme with no grid lines, axis lines on the bottom and left, and a white background. Suitable for most journal submissions.
theme_clean¶
- class plotnine_extra.theme_clean(base_size=14, base_family='')[source]¶
Bases:
plotnine.theme_minimalMinimal clean theme for presentations.
Light grid lines, no axis lines, generous spacing. Good for slides and posters.
theme_scientific¶
- class plotnine_extra.theme_scientific(base_size=10, base_family='')[source]¶
Bases:
plotnine.theme_bwTheme for scientific figures.
Thin axis lines, minimal decoration, serif-friendly. Follows common scientific journal style guidelines.
theme_nature¶
- class plotnine_extra.theme_nature(base_size=7, base_family='Arial')[source]¶
Bases:
plotnine.theme_bwTheme approximating Nature journal style.
Small font sizes, no grid, thin black axis lines, and minimal decoration.
theme_classic2¶
- class plotnine_extra.theme_classic2(base_size=12, base_family='')[source]¶
Bases:
plotnine.theme_bwA classic theme with axis lines and no panel border.
Port of
ggpubr::theme_classic2: white background, no grid, axis lines on the left and bottom only.
theme_pubclean¶
theme_cleveland¶
- class plotnine_extra.theme_cleveland(base_size=12, base_family='', flip=True)[source]¶
Bases:
plotnine.theme_bwPort of
ggpubr::theme_cleveland.A theme suited to Cleveland-style dot plots, with horizontal grid lines and no axis ticks on the y-axis.
theme_transparent¶
- class plotnine_extra.theme_transparent[source]¶
Bases:
plotnine.themePort of
ggpubr::theme_transparent.Sets every panel / plot / legend background element to transparent. Useful when overlaying plots on slides.
theme_poster¶
- class plotnine_extra.theme_poster(base_size=20, base_family='')[source]¶
Bases:
plotnine.theme_minimalHigh-visibility theme for posters.
Large fonts, bold titles, generous spacing. Designed for readability at a distance.
clean_theme¶
- class plotnine_extra.clean_theme[source]¶
Bases:
plotnine.themePort of
ggpubr::clean_theme.Removes axis text, ticks, titles and grid lines while keeping the data ink. Used to declutter ridge plots and summary panels.
Styling Helpers¶
bgcolor¶
border¶
grids¶
rotate¶
rotate_x_text¶
rotate_y_text¶
rremove¶
xscale¶
yscale¶
font¶
- plotnine_extra.font(which='title', size=None, color=None, face=None, family=None)[source]¶
Set the font of a named theme element.
- Parameters:
which (str) – One of
"title","subtitle","caption","x","y","xy","x.text","y.text","xy.text","legend.title","legend.text".size (optional) – Passed straight through to
element_text.color (optional) – Passed straight through to
element_text.family (optional) – Passed straight through to
element_text.face (str, optional) – One of
"plain","bold","italic","bold.italic".
labs_pubr¶
ggpar¶
- plotnine_extra.ggpar(plot, title=None, subtitle=None, caption=None, xlab=None, ylab=None, legend=None, legend_title=None, palette=None, orientation=None, font_main=None, font_x=None, font_y=None, font_legend=None, x_text_angle=None, y_text_angle=None)[source]¶
One-shot setter for plot title / labels / legend / palette.
A subset of the kitchen-sink ggpubr
ggparinterface. The most common arguments are supported; pass any further theme customisations as separate+ theme(...)layers.- Parameters:
title (str | None)
subtitle (str | None)
caption (str | None)
xlab (str | None)
ylab (str | None)
legend (str | None)
legend_title (str | None)
orientation (str | None)
font_main (dict | None)
font_x (dict | None)
font_y (dict | None)
font_legend (dict | None)
x_text_angle (float | None)
y_text_angle (float | None)