我想使用contourf绘制两个不同的3d数据。我希望他们在同一个数字中。问题是我看不到第一个数据。
我正在使用hold,但它并没有解决问题。任何帮助将不胜感激。
答案 0 :(得分:0)
但是,要回答这个问题,通用方法是将轴堆叠在一起。这可以扩展到任意多个轴。
% Generate arbitrary data
test1 = peaks(20);
test2 = fliplr(flipud(test1));
hdl.mainwindow = figure; % Create our main figure
hdl.mainaxis = axes('Parent',hdl.mainwindow); % Create main axis in our figure window
hdl.subaxis1 = axes( ...
'Parent',hdl.mainwindow, ... % Create secondary axis in our figure window
'Position',get(hdl.mainaxis,'Position'), ... % Stack on top of main axis
'XAxisLocation','top', ... % Switch axes locations for visibility
'YAxisLocation','right', ...
'Color','none' ... % Turn off background
);
hold all % Keeps axes from resetting, you'll have to manually adjust everything as needed
[~,hdl.maincontour] = contourf(hdl.mainaxis,test1,10);
[~,hdl.secondcontour] = contourf(hdl.subaxis1,test2,10);
hold off
虽然它在技术上回答了这个问题,但你可以看到它不是一个非常有用的数据表示。
也许是一个子情节?
% Generate arbitrary data
test1 = peaks(20);
test2 = rot90(flipud(test1),2);
hdl.mainwindow = figure; % Create our main figure
hdl.subplot1 = subplot(1,2,1,'Parent',hdl.mainwindow); % Create main axis in our figure window
hdl.subplot2 = subplot(1,2,2,'Parent',hdl.mainwindow); % Create main axis in our figure window
[~,hdl.maincontour] = contourf(hdl.subplot1,test1,10);
[~,hdl.secondcontour] = contourf(hdl.subplot2,test2,10);