【问题标题】:Matlab multiple stacked plotsMatlab 多个堆叠图
【发布时间】:2015-05-08 22:25:26
【问题描述】:

我从未见过像下面这样的情节((a) 中的情节)。甚至可能吗?

【问题讨论】:

  • 这实际上是waterfall plot 的一种形式。这种情节最著名的用法可能是this pulsar data。见waterfall。使用多个重叠轴(或伪造它们)执行此操作将需要一些工作。

标签: matlab plot


【解决方案1】:

根据@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 轴。此外,我们调整了绘图的大小,因此我们将有足够的空间放置其他两个绘图。我们还将颜色设置为无,即透明。

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');

就这么简单,我们得到的东西看起来甚至没有那么糟糕:

【讨论】:

  • 我以前没见过这个参考!我又惊又喜! :P
【解决方案2】:

按照 Horchler 的建议,使用多个 waterfall 绘图:

 %// 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])

我们可以得到这个:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 2019-09-01
    相关资源
    最近更新 更多