Contour map fills outside data points

9 ビュー (過去 30 日間)
Nick
Nick 2013 年 9 月 9 日
Hello all,
I'm attempting to plot 3 vectors of data using contourf. So far, I am using the code below to generate the snap shot attached. As you can see, using this method creates a filled area above the data set as it tries to "connect the dots". Is there a way to prevent this from happening? That is, is it possible to only have the white space above the black line?
x = xData;
y = yData;
z = zData;
xlin = linspace(0,max(x),length(x));
ylin = linspace(0,max(y),length(y));
[X,Y] = meshgrid(xlin,ylin);
Z = griddata(x,y,z,X,Y);
figure
[~,~] = contourf(X,Y,Z);
colormap cool
colorbar
grid on
% Overlay Max Curve
x = xDataMaxSubset;
y = yDataMaxSubset;
hold on
plot(x,y,'LineWidth',2,'Color',[0 0 0])
hold off
% Overlay All pts
x = xData;
y = yData;
hold on
scatter(x,y,10)
hold off

採用された回答

Nick
Nick 2013 年 9 月 9 日
For anyone looking for a solution to a similar problem, this is the workaround I've settled on:
First create additional data points that are 1.1 times the x and y data max subset (just "outside" the original max subset), and fill the corresponding z points with NaN values. Add these x,y,and z pts to the original data sets to be plotted. This will at least prevent the area above the max line from being filled in, though it also makes the fill contour around the max line very choppy. To get around this, add in additional data points along the max line using interpolation until the contour plot looks acceptable.
Cheers!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by