📣 Announcing Plotly.py 4.10: date-axis improvements, a Faster px.imshow() and Full Figures for Development

Update: version 4.12 has been released since this was posted.

I’m happy to announce that Plotly.py 4.10 is now available for download via pip and conda! For up-to-date installation and upgrading instructions (including the extra required steps for JupyterLab!) 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 4.10

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

:mantelpiece_clock: date-axis and px.timeline() improvements

In Plotly.py 4.9 we introduced a new way of making timelines and Gantt charts with the px.timeline() function. In Plotly.py 4.10 we have fixed a number of bugs and long-standing limitations that prevented some people from taking full advantage of this new function:

  1. Plotly Express no longer converts Pandas datetime columns into UTC and instead renders figures “in local time” just like Graph Objects (#2311)
  2. px.timeline() now works with time ranges smaller than 10 seconds. (#2658)
  3. px.timeline() now works even when not all traces have the same categories. (#2684)

Beyond these features, we’ve added some new datetime-formatting options for text on figures, hover labels and tick labels by upgrading to version 4 of d3-time-format: you can now display week (%V) and quarter numbers (%q) in these labels as well as some other frequently-requested options!

Finally, we’ve added a new ticklabelmode attribute to X and Y axes, which lets you build more-intuitive time-series charts by controlling where tick labels go with respect to period boundaries. By default, tick labels in Plotly figures appear below gridlines and represent instants in time such as “00:00 on February 1, 2018” . The tick label text for such an instant can be formatted as “Feb 2018” but it will still appear centered on that instant, meaning that the “F” in “Feb” will appear below data points in January, as in the first plot below. Set the new ticklabelmode attribute to "period" to center tick labels on the period they represent, as in the second plot below, while leaving the grid lines in place at the period boundaries.

Here’s the same feature on a px.timeline() chart:

This feature was anonymously sponsored, and we thank our benefactor on behalf of the community! :pray:

:hammer_and_wrench: Full Figures for Development

Plotly figures support hundreds of different customizable attributes, and these can be hard to learn about and remember. We’ve worked hard in recent months to improve our documentation layout and search system, our figure reference, our Python API reference, and to write some foundational documentation about how figures are structured. In these docs we explain that it isn’t necessary to specify every value of every attribute when constructing a figure, because the Javascript rendering engine underlying Plotly.py, which is Plotly.js, will infer smart defaults for every necessary attribute. In Plotly.py 4.10 we’ve added functionality to let you access the values computed for your figure by Plotly.js from Python via Kaleido.

The new fig.full_figure_for_development() function will return a new go.Figure object, prepopulated with the same values you provided, as well as all the default values computed by Plotly.js, to allow you to learn more about what attributes control every detail of your figure and how you can customize them. This function is named “for development” because it’s not necessary to use it to produce figures, but it can be really handy to explore figures while you’re figuring out how to build them. Check out our new figure introspection documentation for more details and examples.

:racehorse: A Faster px.imshow()

Last November, in Plotly.py 4.3, we added a new function px.imshow() to easily visualize single-channel (heatmap) data as well as multi-channel (image) data. We’ve added a number of features to this function since then and in 4.10 we’ve tackled performance.

The biggest performance problem with px.imshow() and the underlying go.Image() trace has been that data needed to move from Python to Javascript as JSON-encoded lists of lists, and this serialization is very slow. On the Javascript side, an image needed to be synthesized from these large arrays. In Plotly.py 4.10, we’ve modified px.imshow() such that under the hood it will convert its input arrays into base64-encoded images to pass along to Javascript. This results in faster serialization and faster rendering, on the order of 10 times faster!

This can all be controlled by a new set of keyword arguments to px.imshow() such as binary_string, binary_format, binary_compression_level, binary_format and binary_backend, which all have sensible defaults. Simply upgrading to Plotly.py 4.10 will yield performance benefits (especially in Dash apps!), and these arguments can then be tuned for your particular use-case.

:heart: Powered by Plotly.js 1.55 and perfect for Dash 1.16

This release of Plotly.py inherits all of the improvements to the underlying Javascript library that powers it. The full Plotly.js 1.55 changelog contains more details about what changed under the hood.

The version of Plotly.js that Plotly.py 4.10 is built on is the same one that’s bundled with the just-released Dash 1.16 so we recommend that if you’re a Dash user you upgrade to both Dash 1.16 and Plotly.py 4.10 to get the full benefit of all of these libraries working together.

:package: Get it now!

To sum up: Plotly.py 4.10 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, and don’t forget to upgrade your JupyterLab extensions if that is your environment of choice!

:reminder_ribbon: In Case You Missed It: Previous 4.x Announcements

  • 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
  • Plotly.py 4.5:
    • legend titles
    • GeoJSON choropleth improvements
    • a new sunburst/treemap path API
    • uniformtext
  • Plotly.py 4.4:
    • new Plotly Express functions for pie charts, sunbursts, treemaps, funnels maps,
  • Plotly.py 4.3:
    • px.imshow for heatmaps and full-color images
    • facet wrapping in Plotly Express,
  • Plotly.py 4.2:
    • Treemaps
    • Plotly Express input enhancements to work without data frames
    • texttemplate everywhere
  • Plotly.py 4.1:
    • Mapbox maps without Mapbox tokens
    • Choropleth and Density mapbox maps
    • Indicators (big numbers, gauges, bullet charts)
  • Plotly.py 4.0 :
    • offline-only
    • plotly.express-first
    • displayable anywhere
3 Likes

Hi Nicolas,

FYI your ‘changelog’ link is broken. It should be https://github.com/plotly/plotly.py/releases/tag/v4.10.0 and not https://github.com/plotly/plotly.py/releases/tag/v4.10

Best wishes,
Sean

Thanks for the heads up on the typo! I’ve corrected it with the correct link.

1 Like