Remove contour line from unwanted region
7 views (last 30 days)
Show older comments
Hi all, I am able to plot the contour at specific level. However, I want to remove/white out some contour lines from the unwanted region (between -1 to 1 for X and Z). I can create a white space for a 1D matrix (example from other user) with the code below but I have an issue with a matrix (360x180). The code below is not working for 2D matrix. I want to remove the all the contour line when X and Z is between -1 to 1. I have included my .mat file for X_2D,Z_2D and T_2D. Thank you for your kind response.
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
%myCode
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])
0 Comments
Accepted Answer
Wan Ji
on 23 Aug 2021
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
% myCode
T_2D(abs(X_2D)<1 & abs(Z_2D)<1) = NaN; % remove the all the contour line when X and Z is between -1 to 1
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])
Then the result is shown as
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!