绘制python刻面热图
我正在使用的示例。在Python中使用Seaborn进行刻面热图。结果看起来像这样:
我想对Plotly Express做同样的事情,并尝试使用此启动器代码:
import plotly.express as px
df = px.data.medals_wide(indexed=True)
fig = px.imshow(df)
fig.show()
我的数据也位于pd.dataframe
中重要的是,我向这些组表明,热图和地图的X/Y轴分组。
您如何扩展px.imshow
示例以按照上面的海洋示例来创建一个小组的热图?
I'm using the example from this SO Q&A to use seaborn for facetted heatmaps in python. The result looks like this:
I'd like to do the same thing with plotly express and have tried with this starter code:
import plotly.express as px
df = px.data.medals_wide(indexed=True)
fig = px.imshow(df)
fig.show()
My data is also in a pd.DataFrame
and it's important I show the groups the heatmaps are grouped by as well as the x/y-axis of the maps.
How do you extend the px.imshow
example to create a facetted heatmap by group like the seaborn example above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
样本数据是从参考的答复中获取的,以回答问题。如果是列数据,则可以将其作为数据来尺寸,但是结果不能与示例数据中的分类变量一起使用分类变量作为萃取条件。您可以通过在热图中使用图对象作为子图绘制它,可以通过在数据提取结果的数据框架中指定xy轴来创建xy轴。
The sample data is taken from the referenced responses to answer the question. express, as data, can be subplotted if it is column data, but the results cannot be used with a categorical variable as the extraction condition with a different categorical variable, as in the sample data. You can draw it if it is as a subplot using a graph object in A heat map can be created by specifying the xy-axis in the data frame of the result of data extraction by category variable.