Skip to content

Themes API Reference

Themes control the non-data visual aspects of plots such as fonts, colors, and grid lines.

Built-in Themes

ggplotly.themes.theme_minimal

Bases: Theme

Minimal theme that removes background and gridlines for a cleaner look.

__init__(base_size=11, base_family='')

Create a minimal theme that removes background and gridlines.

Automatically applies minimal styling to:

  • Standard 2D plots (white background, no gridlines)
  • 3D scenes (white background, subtle grid)
  • Geographic maps (clean, minimal appearance)
Parameters

base_size : int, default=11 Base font size in points. base_family : str, default="" Base font family (system default if empty).

Examples

from ggplotly import ggplot, aes, geom_point, theme_minimal, data mpg = data('mpg') ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme_minimal() ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme_minimal(base_size=14)

apply(fig)

Apply the minimal theme to a figure.

Parameters

fig : Figure The Plotly figure to which the theme will be applied.

ggplotly.themes.theme_classic

Bases: Theme

Classic theme with white background and no gridlines.

__init__(base_size=11, base_family='')

Create a classic theme with white background and no gridlines.

Similar to ggplot2's theme_classic().

Automatically applies classic styling to:

  • Standard 2D plots (white background, no gridlines)
  • 3D scenes (white background)
  • Geographic maps (light, clean appearance)
Parameters

base_size : int, default=11 Base font size in points. base_family : str, default="" Base font family (system default if empty).

Examples

from ggplotly import ggplot, aes, geom_point, theme_classic, data mpg = data('mpg') ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme_classic() ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme_classic(base_size=14)

apply(fig)

Apply the classic theme to a figure.

Parameters

fig : Figure The Plotly figure to modify.

ggplotly.themes.theme_dark

Bases: Theme

Dark theme with dark background and light text.

__init__()

Create a dark theme with dark background and light text.

Automatically applies dark styling to:

  • Standard 2D plots (via plotly_dark template)
  • 3D scenes (dark background with subtle grid)
  • Geographic maps (dark land, ocean, and borders)
Examples

from ggplotly import ggplot, aes, geom_point, theme_dark, data mpg = data('mpg') ggplot(mpg, aes(x='displ', y='hwy', color='class')) + geom_point() + theme_dark()

apply(fig)

Apply the dark theme to a figure.

Parameters

fig : Figure The Plotly figure to modify.

ggplotly.themes.theme_ggplot2

Bases: Theme

A theme that replicates the default ggplot2 style from R.

__init__()

Create a theme that replicates the default ggplot2 style from R.

Uses Plotly's template system to apply the style across all geoms.

Automatically applies ggplot2 styling to:

  • Standard 2D plots (grey background, white gridlines)
  • 3D scenes (grey background)
  • Geographic maps (grey-toned appearance matching ggplot2)

apply(fig)

Apply the theme's template to the Plotly figure.

ggplotly.themes.theme_bbc

Bases: Theme

BBC-style theme with clean white background and distinctive colors.

__init__()

Create a BBC-style theme with clean white background and distinctive colors.

Automatically applies BBC styling to:

  • Standard 2D plots (white background, BBC color palette)
  • Geographic maps (clean, professional appearance)

apply(fig)

Apply the theme's template to the Plotly figure.

ggplotly.themes.theme_nytimes

Bases: Theme

A theme inspired by New York Times charts.

__init__()

Create a theme inspired by New York Times charts.

Uses Plotly's template system to apply style globally.

Automatically applies NYT styling to:

  • Standard 2D plots (clean white background, subtle gridlines)
  • Geographic maps (clean, professional appearance)

apply(fig)

Apply the theme's template to the Plotly figure.

ggplotly.themes.theme_default

Bases: Theme

Default theme with light background and gridlines.

__init__()

Create the default theme with light background and gridlines.

Automatically applies default styling to:

  • Standard 2D plots (white background, light gridlines)
  • Geographic maps (standard light appearance)

apply(fig)

Apply the default theme to a figure.

Parameters

fig : Figure The Plotly figure to which the theme will be applied.

ggplotly.themes.theme_custom

Bases: Theme

Custom theme with user-specified colors.

__init__(background_color='white', grid_color='grey', text_color='black')

Create a custom theme with user-specified colors.

Parameters

background_color : str, default='white' Background color for the plot. grid_color : str, default='grey' Color of grid lines. text_color : str, default='black' Color of text elements.

apply(fig)

Apply the custom theme to a figure.

Parameters

fig : Figure The Plotly figure to which the theme will be applied.

Theme Customization

ggplotly.themes.theme(legend_position='right', legend_show=True, axis_title=None, axis_title_x=None, axis_title_y=None, axis_text=None, axis_text_x=None, axis_text_y=None, axis_line=None, axis_line_x=None, axis_line_y=None, axis_ticks=None, axis_ticks_x=None, axis_ticks_y=None, panel_background=None, panel_grid=None, panel_grid_major=None, panel_grid_minor=None, panel_border=None, plot_title=None, plot_subtitle=None, plot_caption=None, plot_background=None, legend_title=None, legend_text=None, legend_background=None, strip_text=None, strip_background=None, **kwargs)

Create a custom theme with granular control over plot elements (ggplot2-style).

Parameters

legend_position : str, default='right' Position of the legend ('right', 'left', 'top', 'bottom', 'none'). legend_show : bool, default=True Whether to show the legend. axis_title : element_text, optional Style for all axis titles. axis_title_x : element_text, optional Style for x-axis title. axis_title_y : element_text, optional Style for y-axis title. axis_text : element_text, optional Style for all axis text (tick labels). axis_text_x : element_text, optional Style for x-axis text. axis_text_y : element_text, optional Style for y-axis text. axis_line : element_line, optional Style for all axis lines. axis_line_x : element_line, optional Style for x-axis line. axis_line_y : element_line, optional Style for y-axis line. axis_ticks : element_line, optional Style for all axis ticks. axis_ticks_x : element_line, optional Style for x-axis ticks. axis_ticks_y : element_line, optional Style for y-axis ticks. panel_background : element_rect, optional Background of the plot panel. panel_grid : element_line, optional Style for all grid lines. panel_grid_major : element_line, optional Style for major grid lines. panel_grid_minor : element_line, optional Style for minor grid lines. panel_border : element_rect, optional Border around plot panel. plot_title : element_text, optional Style for plot title. plot_subtitle : element_text, optional Style for plot subtitle. plot_caption : element_text, optional Style for plot caption. plot_background : element_rect, optional Background of entire plot. legend_title : element_text, optional Style for legend title. legend_text : element_text, optional Style for legend text. legend_background : element_rect, optional Background of legend. strip_text : element_text, optional Style for facet strip labels. strip_background : element_rect, optional Background of facet strips. **kwargs Additional Plotly layout parameters.

Returns

Theme A theme object that can be added to ggplot.

Examples

from ggplotly import ggplot, aes, geom_point, theme, element_text, element_rect, data mpg = data('mpg')

Move legend to bottom

ggplot(mpg, aes(x='displ', y='hwy', color='class')) + geom_point() + theme(legend_position='bottom')

Style axis titles

ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme(axis_title=element_text(size=14, color='blue'))

Change panel background

ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme(panel_background=element_rect(fill='lightgray'))

Style plot title

ggplot(mpg, aes(x='displ', y='hwy')) + geom_point() + theme(plot_title=element_text(size=20, color='darkblue'))

Theme Elements

ggplotly.themes.element_text

Customize text elements in themes.

Parameters

size : int, default=12 Font size in points. color : str, default='black' Text color. family : str, default='Arial' Font family.

ggplotly.themes.element_rect

Customize rectangle elements in themes.

Parameters

fill : str, default='white' Fill color. color : str, default='black' Border color. width : int, default=1 Border width in pixels.

ggplotly.themes.element_line

Customize line elements in themes.

Parameters

color : str, default='black' Line color. width : int, default=1 Line width in pixels. dash : str, default='solid' Line dash style ('solid', 'dash', 'dot', 'dashdot').