Contour is plotting my data in reflected order?

I'm using flip to solve this but is this intentional?

댓글 수: 2

KSSV
KSSV 2021년 6월 17일
It depends on your data.
My data:
The temperature is higher at the bottom row in my data, so contour will automatically arrange the top to be higher temperature and reflect my data?

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

 채택된 답변

Joseph Cheng
Joseph Cheng 2021년 6월 17일
편집: Joseph Cheng 2021년 6월 17일
From a quick test you might not be asigning the x and y values when performing your contour() function. by doing so matlab will automatically assign the row and column indexing to match the matrix. So in your example your max data is at the bottom row which is technically the higher value in cartesian coordinates of row 10 (ie y axis 10). you can get around this by defining your x and y values to plot against.
so matrix position (1,1) (row 1, column 1) is top left, but when displayed it'll be bottom left.
%dummy data
[x y]=meshgrid(-5:1:5,-5:1:5);
z = x+(2*y+4).^2;
% plot with just z and then specifying the rows and columns of the matrix z
figure(1),subplot(211),contour(z),colorbar
title('original contour')
subplot(212),contour(-5:1:5,5:-1:-5,z),colorbar

댓글 수: 5

I've actually already assigned x and y in my contour()...
subplot(2,1,1);
[C,h]=contourf(x,y,flip(T));
clabel(C,h);
colorbar;
xlabel('x (mm)');
ylabel('y (mm)');
oh yes but what is x and y? does it follow what i'm discussing here where the first y value y(1) is your most negative or most positive value of y.
Amanda Liu
Amanda Liu 2021년 6월 17일
편집: Amanda Liu 2021년 6월 17일
from 0 to n, yes
n = 10;
X = linspace(0,L,n); % x nodes
Y = linspace(0,H,n); % y nodes
[x y] = meshgrid(X,Y);
so then it would mean that the first row would be denoted at y values of 0 and the last row would be H which i'm assuming here is a positive value. which is why it plots flipped.
Ohh I think I understand now. I'm a total beginner at this. Thank you! ;)

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

추가 답변 (1개)

Steven Lord
Steven Lord 2021년 6월 17일

0 개 추천

Are you trying perhaps to put the contour plot on top of another graphics object, an image perhaps or maybe a pcolor? If so, see the "Change Direction of Coordinate System" example on the documentation page for the axis function.

댓글 수: 1

I'm using subplot only. "Change Direction of Coordinate System" changes all my x,y,T axis but I only want to change the T axis.

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

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 6월 17일

댓글:

2021년 6월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by