문제

MATLAB에서는 X 축의 바닥을 따라 플롯 된 첫 번째 소스가있는 첫 번째 소스와 x 축의 상단에서 플롯 된 두 번째 소스의 단일 그래프를 만들 수 있습니까? 이 작업이 완료된 MATLAB 설명서에서 아무 곳에서나 찾을 수 없습니다.

필자가 필요한 최종 그래프는 다음과 같은 형태로 다음과 같습니다.

http://www.epa.gov/ncer/progress/images/r827933c033_02_003.gif

도움이 되었습니까?

해결책

그래프를 최대한 가깝게 재현하려고 시도했습니다.내가 끝난 일은 다음과 같습니다.

t = linspace(datenum('01-19-2002'), datenum('06-27-2002'), 12);
x1 = randi(40, [12 1]);
x2 = randi(40, [12 1]);
z = 100-x1-x2;

hAxR = axes();
hAxL = axes();

h = bar(t, [x1 z x2], 'stacked');

set(h(1),'facecolor','y')
set(h(2),'facecolor',[.8 .8 .8])
set(h(3),'facecolor','r')
legend(h, {'s1' 's2' 's3'}, ...
   'orientation','horizontal', 'location','northoutside')

set(hAxL, 'xtick',t, 'xlim',[datenum('01-01-2002') datenum('07-15-2002')])
datetick(hAxL, 'x',2,'keepticks','keeplimits')
xticklabel_rotate

ylabel(hAxL, 'label1')
ylabel(hAxR, 'label2')

set(hAxR, 'position',get(hAxL,'position'), 'color','none', 'xtick',[], ...
    'ydir','reverse', 'yaxislocation','right', 'ylim',get(hAxL,'ylim'))
set(hAxL, 'YGrid','on')
.

graph

xticklabel_rotate x 축의 레이블을 회전하려면

다른 팁

bar 기능에 대한 설명서를 확인하십시오.다음과 같은 그래프를 만들려면이를 사용하여 다음과 같은 그래프를 만듭니다.

bar2.gif

bar_ex2.gif

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top