💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

📣 Announcing Plotly.py 4.7 - Performance Improvements and Shape-Drawing

I’m pleased to announce that Plotly.py 4.7 is now available for download via pip and conda! For up-to-date installation 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.

What’s new in Plotly.py 4.7

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

Major Performance Improvements

Plotly.py 4.7 runs significantly faster than 4.6 in many situations, including importing and figure-generation. The biggest performance gains will be felt for users of Python 3.7, as we take advantage of PEP-562 for lazy submodule imports, but earlier versions of Python benefit from the other improvements.

Since Dash depends on Plotly.py, upgrading to this version reduces Dash app boot times and response times for callbacks that make figures, making for a much more pleasant user experience, and developer experience when using hot-reloading… Upgrade to Plotly.py 4.7 and Python 3.7 today if you can!

Shape-Drawing

We have added new layout dragmodes for users to be able to draw shapes such as rectangles, lines, open or closed paths etc. These shapes can also be modified or deleted when activated. In particular, this feature should make it easy to annotate images for measuring objects properties or building training sets for neural nets. The documentation on shapes and images has been updated to illustrate this shape-drawing mode. In order to use the shape-drawing tools, optional buttons need to be explicitly added to the modebar.

The Dash 1.12 release post includes an example showing how to retrieve the geometry of user-drawn shapes, by listening to the relayoutData of a figure in a callback. This new feature paves the way to powerful image processing Dash applications and we are very excited about it!

This development has been funded by the Chan-Zuckerberg Initiative (CZI) Essential Open-Source Software for Science program and we would like to thank CZI for their support.

import plotly.express as px
from skimage import data
img = data.chelsea() # or any image represented as a numpy array
fig = px.imshow(img)
# Define dragmode, newshape parameters, amd add modebar buttons
fig.update_layout(
    dragmode='drawrect', # define dragmode
    newshape=dict(line_color='cyan'))
# Add modebar buttons
fig.show(config={'modeBarButtonsToAdd':['drawline',
                                        'drawopenpath',
                                        'drawclosedpath',
                                        'drawcircle',
                                        'drawrect',
                                        'eraseshape'
                                       ]})

Configurable Plotly Express hoverlabels

If you’ve ever wanted to remove a variable from a Plotly Express hoverlabel or control the formatting of some values, now you can! Check out our improved hover_data options documentation.

Community

Thank you to our community contributors for all the documentation Pull Requests! A special thank you to @zouhairm for their pull-request to allow us to QA Plotly.py builds from unreleased Plotly.js branches: this has helped us move faster already! Thanks also for the mapbox-related PR in Plotly.js which motivated this contribution :slight_smile:

Powered by Plotly.js 1.54 and perfect for Dash 1.12

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

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

Get it now!

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

In Case You Missed It: Previous 4.x Announcements

  • 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

The speed improvements is quite impressive. I’ve a script that generate about 200 plots and the timing went down from 3min 11s to 1min 41s.

2 Likes