如何使用matshow命令生成热图? [英] How to use matshow command to generate heat map?

查看:66
本文介绍了如何使用matshow命令生成热图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有(320,100)矩阵.我想绘制它的热图.矩阵的行应沿x轴,列的应沿y轴.我为此使用 matshow 函数.matshow 函数是否给出沿 x 轴或列的行?在它旁边是从0到100标记x轴,从0到300标记y轴.为什么这样做呢?为什么它不选择矩阵的值?

I have (320,100) matrix. I want to plot its heat map. Rows of the matrix should be along x axis and columns should be along y axis. I am using matshow function for this.Does matshow function gives rows along x-axis or columns? Beside it is labeling x-axis from 0 to 100 and y-axis from 0 to 300. Why it is doing so? why it is not picking the values of the matrix?

[[-0.2706643  -0.25426278 -0.06284858 ..., -0.06432685  0.03350727
  -0.09772336]
 ..., 

 [-0.2630468  -0.2508091  -0.16554087 ..., -0.3019954   0.11554097
  -0.13261844]]

推荐答案

这里是数组的索引方式以及结果 imshowmatshow 绘图的样子.这里的数组形状为 (7,5),因此您有 7 行和 5 列.列是 x ,行是 y .

Here is how an array is indexed and how the resulting imshow or matshow plot looks like. The array here is of shape (7,5), so you have 7 rows and 5 columns. Columns are x, and rows are y.

这里是 imshowmatshow 的区别,imshow 在图表底部有 x 个刻度标签.

Here is the difference between imshow and matshow, imshowhas the x ticklabels on the bottom of the graph.

您可以转置数组,将列变成行,反之亦然.如果 A 是你的数组并且你有 import ed numpy as np,做

You may transpose an array to have the columns turned into rows and vice versa. If A is your array and you have imported numpy as np, do

A = np.array(A).T

这篇关于如何使用matshow命令生成热图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆