Create diagram where y axis has zero limits two times (-1 to 0,0 to 0,0 to 1)
조회 수: 5 (최근 30일)
이전 댓글 표시
Greeting to everyone,
I am trying to write a code that draws a curve like the one in the picture that I attach.My problem is that I cannot find how to set the y axis to take values from -1 to 0,0 to 0,0 to 1. Is it possible to do this in matlab and if so how?
I hope the picture clarifies the problem.Just look at the y values.
Any help would be highly appreciated.Thanks in advance
댓글 수: 0
채택된 답변
Matt Fig
2012년 10월 23일
This will get you started. I include most of the properties you will need to make it look right. You should look at the other axes properties. In particular the 'Ydir' property might come in useful.
ax(1) = axes('pos',[.1 .2 .8 .2],...
'ylim',[-1 0])
ax(2) = axes('pos',[.1 .4 .8 .2],...
'xtick',[],'xcolor','w',...
'ylim',[0 1]);
댓글 수: 6
Matt Fig
2012년 10월 25일
Nobody will laugh, we all have to start somewhere. I am not sure that I can tell what I am supposed to see on your plot, as opposed to what I do see. All I can tell you is that what you are trying to do is not that trivial. You will simply have to play around with the settings until it looks right. Look at it this way: if you persevere through it you will know MATLAB HG like nobody's business!
Here is another demo to help you along in making sure the lines match up:
figure ('name','test','color',[1 1 1])
x = linspace(-pi,pi,1000);
ax(1)= axes('pos',[.1 .2 .8 .2],...
'ylim',[-pi/2 pi]);
hold all
plot(x,tan(x),'.b')
ax(2) =axes('pos',[.1 .4 .8 .2],'xtick',[],'xcolor','w',...,
'ylim',[-pi pi/2]);
hold all
plot(x,-tan(x),'.r')
set(ax(1),'ytick',[-1:2 pi],...
'ytickl','-1|0|1|2|+/-3.14')
set(ax(2),'ytick',[-2:1],...
'ytickl','-2|-1|0|1|2')
I recommend you explore the xtick, xticklabel, xlim, and other such properties of axes objects, starting with reading this:
docsearch('axes properties')
Good luck!
추가 답변 (2개)
Walter Roberson
2012년 10월 22일
If you were to use plotyy() then you could set() the Position of the second axis to be just below the first, and set() YDir to be reversed on one of the plots.
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!