I\'m trying to make a contourf
plot but certain areas of the data array have NaNs (only in the data matrix, the x and y meshgrid matrices are full). I\'d like these
Building on H. Muster's answer, I've artificially created the bands by segmenting the data (you could use a simple function to choose the bands, or create them with contour
on a dummy figure, return them, and re-use them).
[X Y] = meshgrid(10:0.1:50);
Z = X.*Y;
Z(100:300,100:300) = NaN;
figure
hold on;
h = pcolor(X,Y,round(Z/500)*500);
set(h,'Edgecolor', 'interp');
colormap jet;
set(gca, 'XLim', [0 60], 'YLim', [0 60]);
I'm afraid I don't have the toolbox that includes imread
so can't show the underlying gradient, but I think this would work. I've had to increase the resolution by a factor of 10 to get a reasonably smooth image.
Would it be an option to use pcolor instead of contourf
?
[X Y] = meshgrid(10:50);
Z = X.*Y;
Z(10:30,10:30) = NaN;
figure
imshow(uint8(repmat(1:4:240,[60,1,3])));
hold on;
h = pcolor(X,Y,Z)
set(h,'Edgecolor', 'interp');
colormap jet;