Global chart defaults
Set a consistent visual style across charts created in an application.
Plotly · Function
plotly.io.templates stores registered Plotly themes and exposes the global default. Inspect it, select a named template for a figure, register custom templates, or change the default used by new figures.
pio.templates is Plotly's template configuration object. Inspect it to see registered themes, select a template by name for a figure, register custom templates with dictionary-style assignment, or change the default applied when a figure does not specify one.
import plotly.io as pio
pio.templates
pio.templates.default = "plotly_white"
pio.templates["custom_name"] = templateplotly, plotly_white, plotly_dark, simple_white, and none.pio.templates reveals the current default and registered template names.plotly.plotly.graph_objects.layout.Template instances.layout.template.import plotly.io as pio
import plotly.express as px
pio.templates.default = "plotly_white"
fig = px.scatter(x=[1, 2, 3], y=[2, 1, 4], title="Styled scatter")
fig.show()Sets the global default template before creating a Plotly Express figure.
Set a consistent visual style across charts created in an application.
Apply a different theme to one figure without changing global configuration.
Package reusable colors, fonts, and layout conventions for a team.
pio.templates used for?pio.templates is the configuration object for registered Plotly themes. It exposes available templates and supports changing the default through its default property.
Follow-up: How would you inspect the available choices? Evaluate pio.templates or iterate over it with list(pio.templates), which returns registered names.
Set pio.templates.default to a registered template name, such as "plotly_white". New Plotly Express or graph-object figures without an explicit theme then use that default.
Follow-up: How can one disable theming globally? Set pio.templates.default = "none".
A template can be registered by assigning a template object to a name in pio.templates, for example pio.templates["draft"] = custom_template. That name can then be used as a figure template or as the default.
Follow-up: What can a figure's template value be besides a registered name? It can also be a Template object or a dictionary accepted by the constructor.
plotly.io.templates.defaultplotly.graph_objects.layout.Templateplotly.graph_objects.layout.templateplotly.express.defaults