🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

📣 Introducing Plotly.py 5.0.0 - a new federated Jupyter extension, Icicle charts, and Bar chart patterns

Update: version 5.2.1 was released since this was posted.

I’m happy to announce that today we have released version 5.0 of Plotly.py, our flagship data visualization library! 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.

:newspaper: What’s new in Plotly.py 5.0.0

Our official changelog has details and links to individual pull requests, but here are the highlights:

:warning: Backwards-Incompatible Changes

Our commitment to semantic versioning requires us to make this release a major version bump (up from 4.14.3) because we are upgrading to version 2.1 of the underlying Plotly.js library, which makes some backwards-incompatible changes to older and deprecated features (see below), but we see this as a low-risk maintenance release and we expect that the vast majority of users should plan to upgrade without fearing significant issues!

The following features are being dropped or deprecated:

  • Support for Python 2.7 and 3.5 as well as for Internet Explorer 9 and 10 has been dropped.
  • The long-deprecated and un/under-documented area trace type and the legacy scatter.(r|t) attributes have been removed, meaning that the plotly.graph_objects.Area class has been removed.
    • (note the px.area() function still works and has never used the legacy area trace type, which was a polar trace type)
  • The heatmapgl and pointcloud trace types are now deprecated, as are the transforms attributes in any trace in which they appear
  • The latest Plotly.js CDN bundle is no longer being upgraded and will remain pinned to version 1.58.4. HTML Exports from Plotly.py now pin Plotly.js CDN references to the version that is bundled with the version of Plotly.py that generated them.

The following changes have been made to library defaults:

  • Plotly Express now always takes into account every value in category_orders when computing discrete mappings (color, symbol, line-dash, pattern-shapes) as well as facets, even those values which are absent in the data
  • The font size for legend and colorbar titles is slightly bigger, to match axis titles
  • In bar traces, the default textposition is now auto rather than none
  • Legend items will no longer include the long-disliked Aa text unless mode strictly equals text
  • the “modebar” which appears when the mouse cursor is over a plot no longer includes buttons for switching the hovermode between x and closest (closest is now the default) and no longer includes a button for toggling “spikelines”

This release of Plotly.py bumps Plotly.js from 1.58.4 to 2.1, so we recommend that interested users check out our Plotly.js 2.0 release announcement, which includes more in-depth information to the breaking changes in the underlying library. The Plotly.js 2.0 work was partly funded by Equinor, and we thank them on behalf of the community :pray:

:jigsaw: A combined, federated JupyterLab Extension

The major improvement in Plotly.py 5.0 is a much better mechanism for accessing Plotly figures in JupyterLab. JupyterLab 3 added support for “prebuilt” extensions that can be installed via pip or conda automatically, and thanks to an epic community pull request, the two Plotly extensions (jupyterlab-plotly and plotlywidget) have been combined into one prebuilt extension which lazy-loads the large Plotly.js bundle. The upshot of this is that if you’re using JupyterLab 3, you’ll can just pip install plotly (once 5.0 is released!) and you’ll always automatically have the right version of the extension loaded!

Thank you so much to community member @fcollonval for the contribution and for their patience in working through our release process! :heart_decoration:

:checkered_flag: Bar Chart Patterns (aka Hatching or Textures)

Bar charts, histograms and polar bar charts have large markers which support not only a fill color, but as of version 5.0, also an optional pattern (also known as “hatching” or “texture”). This can be used for a variety of reasons:

  • to double-encode variables (i.e. using both color and pattern) to improve accessibility for visually-impaired end-users
  • to encode an additional variable beyond just using color
  • to make charts that are easier to print in black and white

This feature was a community contribution from @s417-lama and we thank them on behalf of the community :bowing_man: !

:ice_cube: Icicle and :fire: Flame Charts

Do you like plotly's sunburst charts but wish they were less circular, but also less nested than treemaps? Then our new icicle charts are for you! They can work in any direction: left to right (or vice versa) for nice text layout, top-down and bluish for the classic icicle look, or bottom up and reddish for the classic flame chart!

This feature was developed by our former colleagues @Kully and @mtwichan of Zyphr and we thank them and their sponsors at Virgin Hyperloop! :heart:

:1st_place_medal: Explicit Legend-Item Ordering

A commonly-requested feature is the ability to reorder a figure’s legend items without needing to change the order in which traces appear in the data object. The new legendrank attribute addresses this need: the default rank is 1000, meaning that any trace can be sent to the bottom of the list if it is the only one with a rank greater than 1000, and the same goes for moving traces to the top of the list with ranks less than 1000. Ties are broken using the current position-in-data logic.

This feature was anonymously sponsored, and we thank our sponsors :bowing_man: !

:racehorse: Faster JSON serialization with orjson

One core performance bottleneck when rendering plotly figures is that they are automatically, internally serialized to a JSON string format for rendering in the browser. This can be quite slow by default for figures containing large numpy arrays or pandas data frames. In this release we have made some progress towards speeding this up, using an optional dependency on the excellent orjson library. When orjson is installed, Plotly.py will automatically leverage it to perform JSON serialization, which can result in 5x-10x performance improvements when the figure contains large arrays.

:dancer: What about Dash?

Plotly.py is always backwards-compatible with Dash, with the caveat that the version of Plotly.js being used in an app must be greater than or equal to the version of Plotly.js used in Plotly.py in order to exploit all the latest features.

Version 5.0 of Plotly.py is based on version 2.1 of Plotly.js, whereas the latest version of Dash is 1.20.0, which is based on Plotly.js 1.58.4. This means that new rendering features like the icicle charts, bar patterns and legend ranks will not be usable in Dash until the next release of Dash, or unless a 2.1 JS bundle is placed in the app’s assets directory. The next version of Dash will have Plotly.js 2.1 built-in and is expected in the coming days.

:package: Get it now!

To sum up: Plotly.py 5.0 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!

:reminder_ribbon: In Case You Missed It: Previous Release Announcements

  • Plotly.py 4.14
    • Faceted and Animated Images and Heatmaps with px.imshow()
    • Inside Tick Labels
    • Smarter Axis Auto-Typing Behaviour
  • 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
  • Plotly.py 4.10:
    • date -axis and px.timeline() improvements
    • Full Figures for Development
    • A Faster px.imshow()
  • Plotly.py 4.9:
    • Kaleido for static image export
    • Hexbin Tile Maps
    • Timelines
  • Plotly.py 4.8:
    • Plotly Express Support for Wide- and Mixed-Form Data
    • a Pandas backend
  • Plotly.py 4.7:
    • Major performance improvments
    • Shape-drawing
  • Plotly.py 4.6:
    • unified hover labels
    • excluding weekends from time-series axes
    • imshow labelling and xarray support
11 Likes

This is incredible work, thanks to the whole Plotly team ! :slightly_smiling_face:

Just a small question about the area trace type that has been dropped in 5.0 : what would be the most efficient way to reproduce such a graph ?

It is mentioned in the forum here to use barpolar trace type, but it seems to me that barpolar trace is still different from a pure area trace type.

Below an area chart in one of my apps I had coded with px.area with Plotly 4.14.3 :

area

Thanks in advance ! Cheers.

Good question! The Area trace type was actually totally unused and undocumented in v4, and in fact the px.area() function does not use the Area trace, so you can continue using px.area() as you have been :slight_smile:

2 Likes

So in the announcement it was stated that:

The next version of Dash will have Plotly.js 2.1 built-in and is expected in the coming days.

Any ETA on this plotly.js 2.1 supported, new version of Dash? Its close to two weeks since this announcement and I was expecting the version bump to occur the same week as plotly 5.0 was released; which I thought was implied from the “in the coming days” part of the statement. Not complaining but it would be great to know what that means. Thanks!

Right, I was hoping we’d have been able to release a new version of Dash by now but things keep getting in the way. I’ll do my best to have it out this week!

4 Likes

Hi All,
I was super excited about the new Icicle Chart that is now possible with Plotly version >=5.0, so I created a tutorial about it to help people learn. If you have any questions, feel free to let me know.

I hope you enjoy your Plotly learning journey.

1 Like