필터 지우기
필터 지우기

Contour Plot in Triangular Box/Frame

조회 수: 3 (최근 30일)
Raees
Raees 2019년 4월 9일
답변: Nitya Patel 2023년 6월 19일
I am trying to make a contour plot for a particular matrix M which is a triangular with real number entries on and above the main diagonal while the entries below the main diagonal are NaN (Not a Number). Enteries below the main diagonal can also be zeros. Because they are neither required in computation nor in the plot. For example,
I am trying to make a contour plot for the above matrix with following code:
contour(X,Y,M,'ShowText','on');
for which I get the following plot:
where X and Y are of the same size as M and obtained as
[X,Y]=meshgrid(x,y);
Question:
Instead of getting the plot in rectangular box/frame as above is it possible to get the contour plot in a triangular frame which should be like below plot?
I’ve tried editing the Axes properties, but that only gives me the freedom of choosing or unchoosing the box to display. It doesn’t allow me to change the plot frame from rectangular to triangular.
I've attached the matrix file for and M matrices.
I'll be grateful for any help / suggestions that can solve my problem. Thanks.
  댓글 수: 1
Hamza SAYYOU
Hamza SAYYOU 2023년 6월 16일
How did you impliment the boudary condition in the slant wall ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Nitya Patel
Nitya Patel 2023년 6월 19일
It is my understanding that you want to plot the contours plots withing a trangular block enclosed between (0,0), (0,1) and (1,0).
I possible workaround for that is to add the boundary line manually, and then remove the figure box.
Here is how you can do that:
load Matrix.mat;
% Plot the contour
contour(X,Y,M,'ShowText','on');
% Hold to plot the boundary in the same figure.
hold on
% Adding the line with black color.
plot([0 1], [1 0], 'k');
hold off;
% Removing the box. gca represents the currect axes or figure.
box(gca, 'off');
Documentation link:

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by