negative values for 'ylim' results in error

조회 수: 16 (최근 30일)
Patrick
Patrick 2011년 9월 27일
Hi,
i'm trying to use the 'ylim'-commad to specify my axes format. Works fine for positive values, but if 'ylim' turns out to be negative i get the following error is there a way bypass this problem:
axes('box','on',...
'LineWidth',2,...
'FontName','times',...
'FontSize',22,...
'ylim',[0 -1.2],...
'YTick', 0:(-1.2/6) :-1.2,...
'xlim',[0 0.3],...
'XTick', 0:0.3/6:0.3);
results in:
??? Error using ==> axes
Bad property value found.
Object Name : axes
Property Name : 'YLim'
Values must be increasing and non-NaN.
Error in ==> XXXX at 76
axes('box','on',...
Great Thanks!
  댓글 수: 1
Andrei Bobrov
Andrei Bobrov 2011년 9월 27일
'ylim',[-1.2 0 ],...
'YTick', -1.2:(1.2/6):0,...

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

채택된 답변

Wayne King
Wayne King 2011년 9월 27일
Hi, if you want to change the direction of the yaxis, you can set 'ydir' to 'reverse'
plot(randn(100,1));
% set(gca,'ylim',[0 -1.2]) gives an error, but
set(gca,'ylim',[-1.2 0]);
set(gca,'ydir','reverse');
is ok.
Wayne
  댓글 수: 2
Wayne King
Wayne King 2011년 9월 27일
The 'ylim' values have to be increasing as the error states
Jan
Jan 2011년 9월 27일
And if you are not sure about the order, because you use variables:
set(gca, 'YLim', sort([a,b]));

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

추가 답변 (1개)

Patrick
Patrick 2011년 9월 27일
sorry i was a bit thick on that one, solved by switching to [-1.2 0] arrg
but thanks anyway!

카테고리

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