I have a set of data.
Day 1: Time=[0 0.1 2.3 4.5 9.0 10.9]; Temp=[22 22.2 24 27.6 21.2 19.3];
Day 2: Time=[0 1.2 2.3 6.4 7.9 9.8 12.1]; Temp=[21 23.2 25 24.3 26 22.6 19.0];
Day 3: Time=[0 3 3.6 8.4 12.1]; Temp=[19.9 21.7 23 21.4 18.7];
What i want to know is that how to plot Temperature (z axis) as a function of Day (x axis) and Time (y axis) using 'stem3'. Also i want to plot each day in different colors.
Please help. I am new and got stuck in this problem.

 Akzeptierte Antwort

dpb
dpb am 21 Mai 2014

1 Stimme

Time=[0 0.1 2.3 4.5 9.0 10.9 nan; ... % data in uniform grid for concise representation
0 1.2 2.3 6.4 7.9 9.8 12.1; ...
0 3 3.6 8.4 12.1 nan nan];
Temp=[22 22.2 24 27.6 21.2 19.3 nan; ...
21 23.2 25 24.3 26 22.6 19.0; ...
19.9 21.7 23 21.4 18.7 nan nan];
Day=repmat([1:3]',1,size(Temp,2)); % day to match
h=[]; % grab the handles
for s=1:3
h(s)=stem3(Day(s,:),Time(s,:),Temp(s,:),'fill');
if s==1,hold on,end
end
set(h,{'color'},{'r';'g';'b'}) % set the colors
The "trick" is that to set the colors diffrently have to have separate stem objects; otherwise if just do
stem3(Day,Time,Temp,'fill','color','r');
, say, the color will be red for all and there's no way to change except all of them as the property is global for the object which is only one. There are two "children" handles only; one for the lines and another for the circles/markers.

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by