I am new to Matlab and your help would be highly appreciated.
My problem is simple.
I plot some diagonal lines at first, and then I plot a data set via the "contourf" command on top of such lines. This data set matrix has some elements defined as NaN, which are not plotted by contourf. As a result, this part of the figure is pure background and a part of the lines are then visible.
Something like:
% Draw diagonal lines X= linspace(4,6,3); Y= linspace(4,6,3);
plot([X(1) 0],[0 Y(1)], 'Color','r', 'linewidth', 1.5); hold on for i=2:length(X)
plot([X(i) 0],[0 Y(i)], 'Color','r', 'linewidth', 1.5);
end
% plot data set with some NaN values via contourf A = repmat(0.25*(1:49)-5.25,49,1); B = repmat(0.25*(1:49)-5.25,49,1)';
C = A.*B;
C(A>3)= NaN; hold on contourf(A, B, C); colormap colorbar
axis([-5 6 -5 7])
print('Test_plot','-dpng','-r800');
As you can see in the example the region that belongs to the C(A>1)=NaN condition is entirely white (i.e. background) while the "colored region" is plotted on top of the diagonal lines.
The displayed picture is exactly what I would like to have when save the image as png. The problem is that when I save it, for some reasons I ignore, the diagonal lines appear on top of the contourf plot. I tried to solve the problem by saving the figure in other formats (e.g. tiff), by playing with the alpha channel, by moving the lines to the background using "uistack", but nothing changed.
Any help?
Thank you in advance.