Matlab 多个堆叠图绘制

8

我从未见过像图(a)一样的情节,它是否可能存在?

enter image description here


3
这实际上是一种“瀑布图”。这种类型的最著名的用途可能是这个脉冲星数据。参见“waterfall”。使用多个重叠轴(或伪造轴)来完成这个过程需要一些工作。 - horchler
2个回答

8
根据@Ander Biguri的个人资料页面:
Matlab甚至可以做你的晚餐,只要你知道如何使用它。这回答了是否可能的问题 ;-)
我们只需要基础的axes命令知识 - 其余只是微调让它看起来好看。让我们来看看:
我们将从创建一些样本数据开始:
t = 100:220;
x1 = -(10*(t-130)).^2;
x2 = -(10*(t-150)).^2;
x3 = -(10*(t-170)).^2;

然后我们将创建一个白色背景的初始图形。
fig = figure(1);
set(fig,'Color','w');

现在我们可以创建一个新的轴对象并将x1绘制在上面:
ax(1) = axes('Position',[0.1,0.1,0.6,0.6]);
plot(ax(1),t,x1+10^4*rand(size(x1)),'-k',t,x1,'-r');

我们将删除坐标轴周围的框,只保留x轴和y轴。此外,我们调整图表大小,以便有足够的空间容纳其他两个图表。我们还将颜色设置为none(即透明)。

set(ax(1),'Color','none');
set(ax(1),'Box','off');
set(ax(1),'Position',[0.1,0.1,0.6,0.6]);

现在我们需要创建第二个图表。我们只需要在喜欢的位置创建另一个轴对象即可:
ax(2) = axes('Position',[0.2,0.2,0.6,0.6]);
plot(ax(2),t,x2+10^4*rand(size(x2)),'-k',t,x2,'-r');
set(ax(2),'Color','none');
set(ax(2),'Box','off');

以及其他类似的内容:

ax(3) = axes('Position',[0.3,0.3,0.6,0.6]);
plot(ax(3),t,x3+10^4*rand(size(x3)),'-k',t,x3,'-r');
set(ax(3),'Color','none');
set(ax(3),'Box','off');

很简单,我们得到的东西甚至看起来并不那么糟糕:

the result


我以前从未见过这个引用!我感到非常惊讶和高兴!:P - Ander Biguri

4
使用多个瀑布图,正如Horchler所建议的那样:
 %// create some sample data
t=10:20:110;
x=0:1:200;
Y=bsxfun(@(x,t) normpdf(x,t,20),x,t.');                                                         %//' fix the code formatting on SO!!

%// Make a colormap to to set the colour of the lines
colormap([1 0 0;0 0 0]);caxis=[0 1];

%// Plot the first set of lines (red ones)
h1=waterfall(x,t,Y,zeros(size(Y)));
set(h1,'FaceColor','none','LineWidth',2) %// tweak the properties
hold on

%// Plot the second set of lines (black lines), just the red lines with some noise
h2=waterfall(x,t,Y+0.002*(rand(size(Y))-0.5),ones(size(Y)));
set(h2,'LineWidth',2)
hold off

view([16 28])

我们可以获得这个: 在这里输入图片描述

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接