Palettes

Palette Scales

color_palette

plotnine_extra.color_palette(palette='default', **kwargs)[source]

Return a discrete plotnine scale_color_manual using the named palette.

Parameters:

palette (str | Sequence[str])

fill_palette

plotnine_extra.fill_palette(palette='default', **kwargs)[source]

Return a discrete plotnine scale_fill_manual using the named palette.

Parameters:

palette (str | Sequence[str])

gradient_color

plotnine_extra.gradient_color(palette='viridis', **kwargs)[source]

Return a continuous plotnine scale_color_gradientn using the named palette.

Parameters:

palette (str | Sequence[str])

gradient_fill

plotnine_extra.gradient_fill(palette='viridis', **kwargs)[source]

Return a continuous plotnine scale_fill_gradientn using the named palette.

Parameters:

palette (str | Sequence[str])

Palette Utilities

get_palette

plotnine_extra.get_palette(palette='default', k=8)[source]

Return k colours sampled from a named palette.

Parameters:
  • palette (str or sequence) – Either one of the names in plotnine_extra.palettes._ggsci, the strings "default" / "grey" / "viridis", a matplotlib colormap name, or a custom sequence of colours.

  • k (int, default 8) – Number of colours to return. If k is larger than the underlying palette, colours are linearly interpolated.

Returns:

Hex colour strings of length k.

Return type:

list of str

set_palette

plotnine_extra.set_palette(plot, palette)[source]

Add color_palette and fill_palette layers to plot.

Parameters:

palette (str | Sequence[str])

change_palette

plotnine_extra.change_palette(plot, palette)[source]

Alias of set_palette().

Parameters:

palette (str | Sequence[str])

show_point_shapes

plotnine_extra.show_point_shapes()[source]

Return a small ggplot showing a set of matplotlib point shapes (mirrors ggpubr::show_point_shapes).

Uses matplotlib’s string marker codes rather than R’s integer shape codes. Integer shapes are not valid matplotlib markers and would crash the renderer.

show_line_types

plotnine_extra.show_line_types()[source]

Return a small ggplot showing the available matplotlib line types (mirrors ggpubr::show_line_types).