I have what I think is a simple problem: I have a matrix that I image using imagesc
. I simply want to show a second y-axis on the right hand side of the image. How do I do that? Example:
我有一个我认为很简单的问题:我有一个用imagesc进行图像处理的矩阵。我只是想在图像的右边显示第二个y轴。我该怎么做呢?例子:
clear all;
aMatrix = rand(20,30);
yAxis1 = 32.*(1:size(aMatrix,1));
yAxis2 = 165.*(1:size(aMatrix,1));
xAxis = 1:size(aMatrix,2);
imagesc(yAxis1, xAxis1, aMatrix);
The following will show the image with yAxis1
, on the left hand side. That is great, but how do I show yAxis2
on the right hand side of the image at the same time? Thanks.
下面将显示左边有yAxis1的图像。这很好,但是如何同时在图像的右侧显示yAxis2呢?谢谢。
1 个解决方案
#1
6
aMatrix = rand(20,30);
yAxis1 = 32.*(1:size(aMatrix,1));
yAxis2 = 165.*(1:size(aMatrix,1));
xAxis = 1:size(aMatrix,2);
h1=imagesc(xAxis, yAxis1, aMatrix);set(gca,'YDir','normal');
ax1=gca;
set(ax1,'YColor','r','YAxisLocation','right');
set(ax1,'XTickLabel',' ');
ax2=axes('Position',get(ax1,'Position'),'YAxisLocation','left');
h2=imagesc(xAxis, yAxis2,aMatrix,'Parent',ax2);
set(gca,'YDir','normal');
#1
6
aMatrix = rand(20,30);
yAxis1 = 32.*(1:size(aMatrix,1));
yAxis2 = 165.*(1:size(aMatrix,1));
xAxis = 1:size(aMatrix,2);
h1=imagesc(xAxis, yAxis1, aMatrix);set(gca,'YDir','normal');
ax1=gca;
set(ax1,'YColor','r','YAxisLocation','right');
set(ax1,'XTickLabel',' ');
ax2=axes('Position',get(ax1,'Position'),'YAxisLocation','left');
h2=imagesc(xAxis, yAxis2,aMatrix,'Parent',ax2);
set(gca,'YDir','normal');