📣 Announcing Plotly.py 4.14: Faceted and Animated Images and Heatmaps, Inside Tick Labels, Better Axis Type Detection

Update: version 5.0 was released since this was posted.

I’m happy to announce that Plotly.py 4.14 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.14

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

:framed_picture: Faceted and Animated Images and Heatmaps with px.imshow()

The px.imshow() function has always allowed you to visualize single-chanel 2-dimensional data as a heatmap, and 3-channel (RGB) 2-dimensional data as an image. As of this release, px.imshow() supports 3- and 4-dimensional single and multi-channel data, via faceting and/or animation. This means that if you have a list or array of images, you can see them all at once side by side using facet_col or you can step through them with a slider using animation_frame, and if you have a list of lists of images, you can use both together! Of course, in addition to working with lists of lists and numpy arrays, this also works well with the xarray library, which is a common way of storing and processing these higher-dimensional arrays.

This feature, like the rest of the px.imshow() function, was sponsored as part of a Chan-Zuckerberg Initiative Essential Open-Source Software for Science grant :heart:

Here are some examples of what this looks like:

:straight_ruler: Inside Tick Labels

For a cleaner look, you can now move the tick labels of your cartesian axes inside the plotting area, and the automatic ranging will leave enough room for the data to not overlap with the tick labels.

This feature was anonymously sponsored. :heart:

:triangular_ruler: Smarter Axis Auto-Typing Behaviour

One issue which has bothered users of Plotly.py for years is that the axis type-detection system in Plotly.js by default treats numeric strings as numbers, which has caused it to automatically consider lists of strings containing a mix of numeric and non-numeric strings as mapping to linear axes and thereby ignoring the non-numeric strings. In Plotly.py 4.14, numeric strings are now treated just like strings that don’t contain numbers for the purposes of axis type detection, which should result in less surprise and confusion, and less need for forcing the axis type to category when passing in lists of strings!

:heart: Powered by Plotly.js 1.58 and perfect for Dash 1.18

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

:package: Get it now!

To sum up: Plotly.py 4.14 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.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
3 Likes

I copied the “cells.tif” into anaconda3/pkgs/scikit-image-0.13.0-py36h398857d_1/lib/python3.6/site-packages/skimage/data/cells.tif

but if I run

import plotly.express as px
from skimage import io
from skimage.data import image_fetcher
path = image_fetcher.fetch('data/cells.tif')
data = io.imread(path)
img = data[20:45:2]
fig = px.imshow(img, facet_col=0, binary_string=True, facet_col_wrap=5)
fig.show()

I get

AttributeError                            Traceback (most recent call last)
<ipython-input-58-2baadef344b3> in <module>()
      2 from skimage import io
      3 from skimage.data import image_fetcher
----> 4 path = image_fetcher.fetch('data/cells.tif')
      5 data = io.imread(path)
      6 img = data[20:45:2]

AttributeError: 'NoneType' object has no attribute 'fetch'

Sorry to annoy you with this, but this new plotting looks really nice

No problem! In general to run our docs you will have to install the contents of https://github.com/plotly/plotly.py/blob/master/doc/requirements.txt and in this case you’re liklely missing the pooch dependency.

1 Like

After installing lots of stuff, it’s running now. This fetcher thing also apparently does not take absolute paths like /User/name/data/cells.tif but with data/cells.tif it works.