stem3 with log axis - recovering stems

I create a stem3 plot with x, y, and z values. When the z-axis is linear, I get stem lines. When I change the z-axis to log, the stems disappear. I would like to recover them somehow.
I am familiar with this issue w.r.t the 2-D stem function http://www.mathworks.com/support/solutions/en/data/1-QB3KB/?solution=1-QB3KB
I'm not able to find corresponding properties for stem3 via the get(gcf), get(gca), and related commands.
1) Is there an equivalent setting(s) in stem3 that will allow this?
2) If not, is there a property that returns the zmin value of the logarithmic z axis? axis returns the values set in linear mode before I changed the z-axis scale property to log
3) Do I need to just code the line generation for log z mode?

 채택된 답변

Matt Fig
Matt Fig 2012년 9월 20일
편집: Matt Fig 2012년 9월 20일

0 개 추천

What happens is that a stem plot has the lines with on point on the z=0 plane. Taking the log of this throws this point to -inf. This works:
X = linspace(0,1,10);
Y = X./2;
Z = sin(X)*2000 + cos(Y)*2000 + 1e3;
L = stem3(X,Y,Z,'fill');
C = get(L,'child');
Zd = get(C(1),'zdat')
Zd(Zd==0) = 1; % No zeros in the data!
set(C(1),'zdata',Zd)
set(gca,'zscal','log')

댓글 수: 4

Matt Fig
Matt Fig 2012년 9월 20일
편집: Matt Fig 2012년 9월 20일
Ravi commented:
"This is intriguing, thank you. I recognize from the 2-D stem analog that drawing down to the z=0 plane is not defined for logarithmic axes.
Where I am still confused is that in my specific situation, my z-values (99 of them) are all > 0. But, when I replicate pieces of your recommendation, I get zdat values of 0 and NaN along with the data I passed to stem3. Not sure why this is or why the zdat has 186 elements. Is there more on the data structure so I can understand what the get commands are returning?
I think I need to set the equivalent of Z(Z==0) to my zmin value. The NaNs are puzzling."
Matt Fig
Matt Fig 2012년 9월 20일
편집: Matt Fig 2012년 9월 20일
The reason that the zdata has nans is that it is used to generate lines. The nans separate different lines. The zeros are the bottom endpoints of the lines.
Your data is fine if it is all >0. The problem is that MATLAB stores the line endpoints as starting from 0. That is why I manipulated the zdata, not the original Z I passed to the function.
Ravi
Ravi 2012년 9월 20일
Ah! This works and I understand why. I appreciate the fast and detailed responses.
Matt Fig
Matt Fig 2012년 9월 21일
You're welcome. I appreciate the courteous feedback!

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

추가 답변 (0개)

카테고리

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

태그

질문:

2012년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by