Using multiple pcolor lines to graph

Hello. I have a quick question. I have taken 11 data sets and have found a mean temperature at a certain height and time. I then plotted these values in pcolor to create a heatmap. However, when plotting and whether I used 'hold on' or 'hold off' I found that the graph would only plot the first line of pcolor, or the last. Is there anything I need to do in order to have all 11 lines of pcolor plot? Thank you in advance.

Antworten (1)

Walter Roberson
Walter Roberson am 11 Mai 2018

0 Stimmen

If you are trying to say that you are getting out 10 color faces instead of 11 color faces, then the answer is that you cannot do that in pcolor. pcolor is surf() followed by view(2). surf() interpolates the color of faces at the center of the four vertices that define the corners of the face, so surf() and thus pcolor() will always have one fewer row and one fewer column than the input data.
If your data is on a regular grid instead of at irregular locations (pcolor and surf permit irregular locations) then I suggest you use imagesc() instead of pcolor().
You could also look at using warp(), which does permit irregular locations.

5 Kommentare

I do not think that is my problem. Let me try to explain again. I have this in my code in order to plot the different data sets:
figure(1)
pcolor(x1,y1,temp1);
pcolor(x2,y2,temp2);
pcolor(x3,y3,temp3);
pcolor(x4,y4,temp4);
pcolor(x5,y5,temp5);
pcolor(x6,y6,temp6);
pcolor(y7,y7,temp7);
pcolor(x8,y8,temp8);
pcolor(x9,y9,temp9);
pcolor(x10,y10,temp10);
pcolor(x11,y11,temp11);
When I run the program, the first line of pcolor only plots. If I add a 'hold on' or 'hold off' to the list, the last graph is the only one that plots. I want to create a heatmap that has every line listed below incorporated in the graph.
When you speak of irregular grid, I am not sure what that is referring to. I think the grid is regular- x-values are time (110600:500:143100), y-values are height (0:10:100), and temp is a 3X10 matrix containing a value for each height, incremented in time.
Walter Roberson
Walter Roberson am 11 Mai 2018
If you had "hold on" after the first pcolor() then everything would be plotted. However, you are placing everything at exactly the same location, and you are making everything opaque.
You need to decide how you want the data to be drawn together:
  • take the mean at each location over the 11 matrices and draw that
  • take the minimum at each location etc
  • take the maximum at each location etc
  • take the median at each location etc
  • convert each value in each matrix into a color, and take the mean of the RGB components and draw that
  • convert each value in each matrix into a color, and take the maximum of each RGB components and draw that
  • convert each value in each matrix into a color, convert the RGB to HSV, take the mean of the HSV components, convert back to RGB and draw that
  • do not change any value, draw them all, but impose transparency on them -- if you do then remember that each alpha operation is layered so an alpha value of 1/10 that is two layers down does not have the same total contribution to the output as an alpha value of 1/10 on the top layer.
That is exactly my problem- when I add 'hold on', the graph does not include all 11 pcolor-lines, but only the last. Without 'hold on', the program only includes the first pcolor-line. Is there a way to fix this?
I have varying times for each line, and have used meshgrid to combine the times with heights- so though the heights are all the same, the varying factor is time, and the temperature should be plotted accordingly.
lower = 0; %find mean temperature values
index=1;
tlower=142900;
m11=zeros(20,1);
for tupper=143400:500:143900
for upper=10:10:100
m11(index)=mean(T11(find((ftime11>tlower & ftime11<=tupper) & ((z11>lower &z11<=upper)))));
index=index+1;
lower=upper;
end
tlower=tupper;
end
t1k=m11(1:10,1); %assign temperature values to array
t2k=m11(11:20,1)
temp11=[t1k t2k];
Ts11=[142100 142600]; %assign time values
Zs11=[5:10:95]; %assign height values
[x11,y11]=meshgrid(Ts11,Zs11);
Currently, for each data set, I have this to find the values I need. Once this is done, I have the code to graph. Is there something I am not doing correctly?
Thank you for your help.
Walter Roberson
Walter Roberson am 12 Mai 2018
I think the lower = 0 should be inside the "for tupper" loop, before the "for upper".
Wafa'a Shanti
Wafa'a Shanti am 13 Mai 2018
I just tried this, and the same results happened. I noticed thought that I was mistaken- when I add the 'hold on' function, the resulting graph only has the first pcolor-line, and does not include the rest. Is there supposed to be another line of code for pcolor that I am missing?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 10 Mai 2018

Kommentiert:

am 13 Mai 2018

Community Treasure Hunt

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

Start Hunting!

Translated by