hold data from a regular plot to a semilog plot

조회 수: 31 (최근 30일)
j dr
j dr 2011년 3월 15일
I hope this one is easy: Imagine I already have figure 100 in a plot containing data, and I want to add more curves while making the plot in a semilogy scale. let's say the data I have can be produced by: figure(100) plot([0,1,2],[900,1200,1000]) (and we can't change that)
I am now using hold on semilogy(0,1000) hold off but the plot remains normal (due to hold on I'm assuming)
in order to have my complete set of data as it would be traced by figure(100) semilogy([0,0,1,2],[1000,900,1200,1000])
I tried using reset, plotnow but I can't seem to access the axes handle's properties in order to make them semilog.
Thank you, N.

채택된 답변

Matt Fig
Matt Fig 2011년 3월 15일
It is not clear to me whether you want to have two different curves, one in linear scale and the other in logarithmic scale or whether you want to change one existing plot to have the y-axis be log scale. If the latter, you can do:
set(gca,'yscale','log')
If the former, look at the PLOTYY function.

추가 답변 (1개)

j dr
j dr 2011년 3월 16일
Exactly the former.
I tried using gca, and then trying get on the value 170.0012 but get couldn't recognize the handle...
If I use get(gca) then it works... do you know why that is ? If I knew that I could have figured that out myself, but thanks a lot for being very insightful !
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 3월 16일
Handles are 64 bit floating point quantities, the full extent of which is not shown with any of the "format" choices except for "format hex".
Matt Fig
Matt Fig 2011년 3월 16일
The handle is a double number. You only pasted the first 4 decimals, which is not enough, in fact you may not be able to copy and paste even if you set the format to long g. That is why we store handles in variable, like:
ax_handle = gca;

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

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by