Update: version 5.7.0 was released since this was posted.
I’m happy to announce that Plotly.py 5.2.1 is now available for download via pip
and conda
! For up-to-date installation and upgrading instructions please see our Getting Started documentation page and if you run into trouble, check out our Troubleshooting Guide.
What’s new in Plotly.py 5.2.1
Our changelog has details and links to individual pull requests, but here are the highlights:
New Least-Squares and LOWESS Trendline Options
Plotly Express has always had the ability to run Ordinary Least Squares (OLS) regression and draw the resulting lines on a plot, as well as Locally WEighted Scatterplot Smoothing (LOWESS) trendlines, but until this new release, neither exposed any parameters that could be tuned. With the new trendline_options
argument in version 5.2.1 it’s now possible to run OLS regression on log-transformed data, and to tune the fraction of the data that LOWESS uses for smoothing so as to control how “wiggle” the smooth is.
It’s also now finally possible to draw an overall trendline for the whole dataset (including across facets and animation frames!) when using discrete colors or symbols, using the trendline_scope
argument.
import plotly.express as px
df = px.data.gapminder(year=2007)
fig = px.scatter(df, x="gdpPercap", y="lifeExp", color="continent", log_x=True,
trendline="ols", trendline_options=dict(log_x=True),
trendline_scope="overall", trendline_color_override="black",
title="Log-scaled X axis and log-transformed fit", height=500)
fig.show()
New Trendline Types: Moving Averages and more
In addition to the new features for existing trendline types "ols"
and "lowess"
, version 5.2.1 includes support for Pandas-powered "rolling"
, "ewm"
and "expanding"
trendlines, which makes it possible to draw plots with moving-average trendlines with various configuration options, as well as more exotic trendlines like expanding-maximum trendlines or exponentially-weighted moving averages etc.
import plotly.express as px
df = px.data.stocks(indexed=True, datetimes=True)
fig = px.scatter(df, y=["GOOG", "MSFT", "FB"], trendline="rolling",
trendline_options=dict(window=5),
title="5-point moving average", height=500)
fig.show()
Empirical Cumulative Distribution Function (ECDF) Plots with px.ecdf()
One specific type of plot that could be built using the new "expanding"
trendline above is an Empirical Cumulative Distribution Function (ECDF) plot, but to make it easier to make this kind of figure, version 5.2.1 includes a dedicated px.ecdf()
function with various options that work similarly to other distribution-visualizations like histograms. Coloring, faceting, marginal plots etc are supported just like in any other Plotly Express plot.
import plotly.express as px
df = px.data.tips()
fig = px.ecdf(df, x="total_bill", color="sex")
fig.show()
Markers in px.line()
By popular demand, we have added a boolean markers
argument to px.line()
to be able to show markers at each data point, and we have also added a symbol
argument to be able to use different symbols for different lines, which should increase accessibility and make it easier to read figures in black and white.
import plotly.express as px
df = px.data.gapminder().query("continent == 'Oceania'")
fig = px.line(df, x='year', y='lifeExp', color='country', markers=True)
fig.show()
New geo
projections
Due to an upgrade to the underlying D3 library, version 5.2.1 supports many new geographic projection types for outline maps, bringing the total number of possibilities to a whopping 83!
Sharper WebGL Rendering
In this release we have tweaked Plotly’s WebGL rendering code, so that WebGL-powered figures render much more crisply with fewer “fuzzy” or pixelated edges.
What was new in Plotly.py 5.1.0
We didn’t put out an announcement for Plotly.py 5.1.0 when it came out, but you can check out its changelog as well.
Legend Group Titles
Plotly legends now support titles for legend groups, allowing for more structured legends while we wait for another sponsor to step up and permit us to finally add support for multiple legends.
This feature was anonymously sponsored .
Powered by Plotly.js 2.3.1 and perfect for the upcoming Dash 2.0
The version of Plotly.js that Plotly.py 5.2.1 is built on is the same one that will be bundled with the upcoming Dash 2.0 release so we recommend that if you’re a Dash user you upgrade to Dash 2.0 once it’s out, to get the full benefit of all of these libraries working together.
Get it now!
To sum up: Plotly.py 5.2.1 is out and if you’re excited about any of the above features, head on over to our Getting Started documentation page for full installation instructions!
In Case You Missed It: Previous Announcements in the Past Year
- Plotly.py 5.0
- A combined, federated JupyterLab Extension
- Bar Chart Patterns (aka Hatching or Textures)
- Icicle and Flame Charts
- Explicit Legend-Item Ordering
- Faster JSON serialization with
orjson
- Plotly.py 4.14
- Faceted and Animated Images and Heatmaps with
px.imshow()
- Inside Tick Labels
- Smarter Axis Auto-Typing Behaviour
- Faceted and Animated Images and Heatmaps with
- Plotly.py 4.13
- Magical error messages
- Performance improvements (including for Dash!)
- Faceted Maps
- Plotly.py 4.12:
- Horizontal and vertical lines and rectangles
- Plotly.py 4.11:
- Period positioning on
date
axes
- Period positioning on
- Plotly.py 4.10:
date
-axis andpx.timeline()
improvements- Full Figures for Development
- A Faster
px.imshow()