Changes in Version 6 in Python
Guide to changes in version 6 of Plotly.py and how to migrate from version 5
New to Plotly?
Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
This page outlines the changes in Plotly.py version 6 and cases where you may need to update your charts or tools that you use for working with Plotly.py.
Jupyter Notebook Support¶
Versions of Jupyter Notebook earlier than version 7 are no longer supported. To upgrade to the latest Jupyter Notebook:
pip install notebook --upgrade Click to copy
Change to anywidget for go.FigureWidget¶
go.FigureWidget now uses anywidget. Install anywidget
with:
pip install anywidget
Processing NumPy and NumPy-Convertible Arrays¶
Plotly.py now takes advantage of recent changes in how Plotly.js handles typed arrays for improved performance. See the performance page for more details.
Dataframe Support¶
Plotly Express now uses Narwhals to natively support pandas, Polars, and PyArrow. With this change, the performance of using Polars or PyArrow with Plotly Express is significantly improved.
Mapbox Deprecation¶
Mapbox-based traces are deprecated and will be removed in a future version of Plotly.py. Use Maplibre-based traces instead.
Removed Attributes¶
The following attributes have been removed in Plotly.py 6.
titlefont
,titleposition
, titleside
, and titleoffset
¶
The layout attributes titlefont
,titleposition
, titleside
, and titleoffset
have been removed. Replace them with title.font
, title.position
, title.side
, and title.offset
.
The following example shows how to use layout.title.font
:
import plotly.graph_objects as go
fig = go.Figure(
data=[
go.Bar(
x=["A", "B", "C", "D"],
y=[10, 15, 13, 17]
)
],
layout=dict(
title=dict(
text="Chart Title",
font=dict(
size=40
)
)
),
# Previously the title font could be set like this:
# titlefont=dict(size=40)
)
fig.show()
Removed Traces¶
The following traces have been removed.
heatmapgl
¶
The heatmapgl
trace has been removed. Use heatmap
instead.
pointcloud
¶
The pointcloud
trace has been removed. Use scattergl
.
Other Removed Features¶
Transforms¶
Transforms, which were deprecated in Plotly.py v5, have been removed. You can achieve similar functionality by preprocessing the data with a dataframe library.
For example, a transform to filter the data:
dict(
type = 'filter',
target = df['year'],
orientation = '=',
value = 2007
),
Could be rewritten using Pandas:
df_2007 = df[df['year'] == 2007]
What About Dash?¶
Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
Learn about how to install Dash at https://dash.plot.ly/installation.
Everywhere in this page that you see fig.show()
, you can display the same figure in a Dash application by passing it to the figure
argument of the Graph
component from the built-in dash_core_components
package like this:
import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or any Plotly Express function e.g. px.bar(...)
# fig.add_trace( ... )
# fig.update_layout( ... )
from dash import Dash, dcc, html
app = Dash()
app.layout = html.Div([
dcc.Graph(figure=fig)
])
app.run_server(debug=True, use_reloader=False) # Turn off reloader if inside Jupyter