Plot issue (maybe using set and gca)

Hey guys, here is the code that I have:
stem(Tim,Var1,'MarkerSize',0,'Color','k'); hold on;
stem(Tim,Var2,'MarkerSize',0,'Color','g');
stem(Tim,Var3,'MarkerSize',0,'Color','r'); hold off;
datetick('x','mm/dd');
set(gca,'YTickLabel',{0; 1; 2; 3;})
So for a specific length of time, Var1 = 1, Var2 = 2, Var3 = 3. I expect my Y axis to represent this, and the stem for each Var should rise to the associated value.
However, when I plot, this is not the case. Here is what actually happens:
Any help or advice on this issue would be much appreciated!
EDIT*** For this plot's time period, Var2 should be the only one showing.

댓글 수: 6

Sarah
Sarah 2012년 5월 5일
anyone have any suggestions for this?
Oleg Komarov
Oleg Komarov 2012년 5월 5일
You're using the same Tim for all stems.
Sarah
Sarah 2012년 5월 5일
I don't see how this is an issue though
Oleg Komarov
Oleg Komarov 2012년 5월 5일
Var2 is 2 in your example and Var3 is 3, how then Var2 should be the only one appearing. Also, I cannot reproduce what you show on the picture. If you want meaningful answers give more details about your problem and what you want to achieve.
Sarah
Sarah 2012년 5월 5일
Because all Vars are defined as absolute time ranges. It just turns out that for the time period that I have plotted in the x axis, Var2 is defined.
Think of the Vars as "events" that occur during absolute time. I just want a record of those events.
Sarah
Sarah 2012년 5월 5일
Var3 does not occur within the time period that I have plotted

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

답변 (1개)

Sarah
Sarah 2012년 5월 5일

0 개 추천

I have thought about it a little more. I think this has to do with my YTickLabel. Basically, I have to make sure that the label corresponds with the value of Var.
Does anyone know how I can make each YTick correspond with the value of Var1 - 3?

카테고리

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

질문:

2012년 5월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by