필터 지우기
필터 지우기

how do I modify the axis in plot(x,y)?

조회 수: 2 (최근 30일)
claudio
claudio 2011년 3월 7일
답변: laurent jalabert 2019년 5월 23일
Hi, I need to plot the following vectors: x=[0.05 0.1 0.3 0.5 1 5 10 20 30 40 50] y=[0.8 0.83 0.9 0.93 0.93 0.9 0.9 0.94 0.95 0.95 0.95] plot(x,y)
My problem is that the vector x don't appears explicitly in the axis and also the scale of the axis is not constant. I need something like:
----------------------------------------------------
0.05 0.1 0.3 0.5 1 5 10 200 ...
your help will be very useful for me

채택된 답변

Matt Tearle
Matt Tearle 2011년 3월 7일
So you want the x-axis to be nonlinear (but not necessarily log)? Well, you can always cheat. Do what Matt Fig suggests, but change the plot command to just plot(y) and the next line to
set(gca,'XTick',1:length(x))
  댓글 수: 2
claudio
claudio 2011년 3월 8일
thank you very much, this work fantastic!!
I appreciate you response.
PD: are there any way to put the first and the last point not on the vertical axis but to leave a interval for to have a better vision of these points in the graphic?
I used to use axis([xmin xmax ymin ymax]) but now doesn't work :(
Matt Tearle
Matt Tearle 2011년 3월 8일
I'm not sure I understand what you're after. If you want to leave a bit of space above and below the data, just use axis or ylim and pad it out a bit: ylim([ymin-dy ymax+dy]) (where dy is some small "padding" value)

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

추가 답변 (2개)

Matt Fig
Matt Fig 2011년 3월 7일
Is this more to your liking?
x=[0.05 0.1 0.3 0.5 1 5 10 20 30 40 50];
y=[0.8 0.83 0.9 0.93 0.93 0.9 0.9 0.94 0.95 0.95 0.95];
plot(x,y)
set(gca,'xtick',x);
set(gca,'xticklabel',num2str(x.'));
Now, separately try this and see if it is what you need. When you have such large differences in scale, there can be problems representing all the data points on an axis.
set(gca,'xscale','log') % Set to linear to go back.
  댓글 수: 1
claudio
claudio 2011년 3월 7일
Ok Matt Thanks,
Now, I just need to represent all the data points on x axis uniformly, but I can't find the way. Could you help me pls?

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


laurent jalabert
laurent jalabert 2019년 5월 23일
hello, what about a function to modify the xTicks label with a non-linear function of x ?
For example, displaying the grid as x^3 ?

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by