2D plot by including third parameter as colorbar

I have 3 matrices (X Y and Z). Among these X and Z are of same size, that means same number of rows and columns. the second one Y is a column vector with same number of rows of X and Z. I need to create a plot between these three.The x axis will be matrix X and y axis will be vector Y. The values in Z matrix corresponding to X and Y matrix is represented in the plot and the values should show as colorbar.
Can anyone help please? I will be so grateful.
[SL: the text was formatted as code. Formatted it as text instead.]

댓글 수: 2

Hank
Hank 2020년 3월 10일
see this thread: https://www.mathworks.com/matlabcentral/answers/5042-how-do-i-vary-color-along-a-2d-line
I got the figure like this.. the problem is that the left and right portion should be blue and middle portion should be red according to the value..but the left side is only blue and middle and right side is blue...according to colourbar and the value in Z axis is near to blue in colorbar

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

 채택된 답변

Piyush Lakhani
Piyush Lakhani 2020년 3월 12일

0 개 추천

The simplest way to doing this is by using the 'surf' or 'contourf' functions.
But, for that you need to create m x n matrix for all three variables. First convert Y from column to Row and then use 'meshgrid' comand to create Y as same size as X.
Y=Y';
Y=meshgrid(Y);
Y=Y(length(X),:);
Then use countourf
contourf(X,Y,Z)

댓글 수: 2

but using this code, both X and Z is getting plotted in the figure as line and shade respectively. I need to display only Z matrix as line and I need shade in between all lines.
I created a contour plot and made it two dimension using view(0,90).
Thanks for the help

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

추가 답변 (0개)

카테고리

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

질문:

2020년 3월 10일

댓글:

2020년 3월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by