matlab - Matlab: Is it possible to change image axis labels automatically to fit my data?
问题描述
I'm experimenting with using imagesc
function because I need to make a 2D color plot of 3D data, where the color indicates the strength of signal output for each combination of 2 inputs, and the x and y axes should represent the input parameters. I looked at this question, which is similar:
How to change image axis labels
The problem is that I don't know beforehand the range of values that my input parameters will have, and they're not necessarily "nice", "round" numbers either, that can be spaced by 10 or some other integer. Worse, depending on the test that I do, my data might have the order of inputs inverted. For instance, if I manually set the x-axis to go from low to high values (as is standard), it may actually be backward from how my data actually is, if my parameter values were being input from high to low.
example of my output image using imagesc function
I included an example of the image that I got so far. The y-axis was left as default, which simply shows that I have over 180 rows in the matrix of my output signal. I changed the x-axis by using linspace
to correspond to the range of input parameters from lowest to highest value. However, the image should be flipped horizontally, because I know that the yellow spot on the right should correspond to low values on the x-axis--that is, it should be on the left side.
So I need to make this happen automatically, that the strength of my output signal gets correctly matched to the combination of 2 input parameters (which are shown on the x & y axes), and the output for each combination is represented by a color on a color scale.
Is there just no way to do this using imagesc
? Do I have to use the pcolor
function instead? Or is there some other approach?
解决方案
使用该pcolor
功能,我得到了我想要的。它直接将(矩阵)变量之间的直观关系转换为具有正确轴比例的图形图像。我有 3 个变量;让我们称它们f
为 ,H
和Z
。关键是制作一个颜色图,其中的值Z
对应于每个唯一f
的H
值对,类似于 x,y 坐标。所以,我制作f
了H
矩阵(具有相同的维度),其中f
所有列都是一个列向量的副本,并且H
所有行都是一个行向量的副本。(Z
已经是一个矩阵,具有相同的维度。)这样,如果我从两个矩阵中选择一个 i,j 元素f
,H
我会得到一个唯一的f
,H
对,并且可以将其映射到 中的 i,j 元素Z
。然后简单地使用:
pcolor(f,H,Z)
我得到这样的图像(带有一些附加命令): f,H color plot example
轴编号标签会自动调整以匹配f
和H
值。
推荐阅读
- css - 使缩略图垂直后,图像比 flex-viewport 更宽
- reactjs - 模块构建失败:UnhandledSchemeError:从“别名:/路径”读取不是由插件处理(未处理的方案)
- json - Dart 中如何生成自定义 json 数据?
- linux - 从终端输出中获取多行
- python - 检查整数是否在二等分列表中,列表对于内存来说太大了
- tensorflow - 在反向传播期间是否总是使用梯度下降来更新权重?
- xamarin.forms - Xamarin Froms 和 SkiaSharp,突出显示图像上的区域
- reactjs - React:如何使用功能性 usestate/useEffect 复制特定的组件类 setstate 回调示例?
- asynchronous - 任务看门狗被触发 - 任务没有及时重置看门狗
- java - persistence.xml 是否支持 *.xml?