필터 지우기
필터 지우기

axes problem in a plot

조회 수: 1 (최근 30일)
joo
joo 2012년 11월 15일
how can i solve the problem of this two images automatically without having to fix the axes range for each plot (i have millions of these plots)?
(problem: axis shoud be for x[0 18]) and for y[-6 6]
(problem: the minimum x and minimum y should be bigger)
thank you so much.

채택된 답변

Matt Fig
Matt Fig 2012년 11월 15일
You can set the axes limits to be a certain percent of the data or fixed values, depending on what you want.
x = -pi:.001:pi;
y = sin(x).*x.^2;
plot(x,y)
axis([-5 5 -6 6]) % Use this to set the limits as needed
  댓글 수: 9
Matt Fig
Matt Fig 2012년 11월 15일
편집: Matt Fig 2012년 11월 15일
In that case, something like this might be preferable:
x = pi:.001:2*pi;
y = sin(x).*x.^2 + 1;
plot(x,y)
xt = get(gca,'xtick');
dx = xt(2)-xt(1);
yt = get(gca,'ytick');
dy = yt(2) - yt(1);
pause(1)
axis([xt(1) - dx,...
xt(end) + dx,...
yt(1) - dy,...
yt(end) + dy])
Part of the problem is that we could go on forever trying to make your plot look just like you want it to look. I have tried to provide you with some tools to think about, play with, and apply to your particular data.
joo
joo 2012년 11월 15일
your code works with my data for 2D but when i work in 3D it doesn't. i will send you my code and excel file by email. if you don't mind to take a few minutes to see the problem, i would be very grateful.
if you can't, thank you very much as well for ALL your help and kindness!
thank you so much.

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

추가 답변 (0개)

카테고리

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