I want to quickly create heatmaps where I already have proper data for the all the dimensions and do not need any of the preprocessing that comes with px.density_heatmap. So for now it seems that I need to revert to graph_objects to accomplish that, since there is no px.heatmap. Is there a reason for that? Or is it just not ready yet?
Hi @realtime, if your heatmap corresponds to 2d image data, you can use the
px.imshow function which was introduced in plotly 4.3, and works for 2d single-channel or RGB images. The documentation is on https://plot.ly/python/imshow/. However, it makes some opiniated choices for you, like the
[0, 0] element is at the top-left corner (as in an image) and pixels are square. We might extend the API later for a more traditional
px.heatmap, for other data than images.
I found another way, probably (slightly) illegal:
import plotly.express as px iris = px.data.iris() fig = px.scatter_3d(iris, x="sepal_width", y="sepal_length", z="petal_length") fig.data._props['type'] = 'heatmap' fig.show()
The results look as I would expect them to look, but unfortunately the axis titles are lost with that approach.
Just a thread bump to inquire if a formal
px.heatmap is on the roadmap…? It would be great to be able generate heatmaps quickly from tidy data (
pd.DataFrame with columns to assign to
z instead of 2D
img data) with the same ease that other tidy
px graph types can be created! Thanks.
Agreed. Plotly designers, could we please have this?
We’ve expanded the capabilities of
px.imshow() quite a bit since this post was created… Check it out at https://plotly.com/python/imshow/
In addition, Plotly Express has always had
px.density_heatmap() which accepts slightly different inputs: https://plotly.com/python/2D-Histogram/
I’d be curious to understand what function signature folks are looking for that’s not close to one of those two
If you accept answer from a novice user…
Method posted by ‘realtime’ is (almost) what I need. I tried density_heatmap and imshow but couldn’t get satisfactory results.
I mean I think I know how to get there with mentioned two methods but few extra steps are required. With realtime’s method I get straight translation of values to color without bins and no need for manual mapping. Graphs from both ‘legal’ methods look quite different from what I expected, while ‘illegal’ get me right to where I wanted to be (almost ).
That said… let me thank you for Plotly. I think… No, I’m sure! it is awesome! Thank you very much for it.