How to use Xlim which refer to one x-axis in yyaxis function?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi! I have a question about how to use xlim in yyaxis function which refer to one x-axis. I have two types of chart in one figure. They both have different x-axis and y-axis. One y-axis has a reversed value and I want its x-axis value refer to the other one. I try to find the example in mathworks question but I could not find it. Could you please help me? Here is the code I wrote:
%%Plot Flow [l/min] and Cumulative Rainfall Depth [mm] (Figure 3)
x1=flowCSV{:,'DateAndTime'};
x2=rainanalysis{:,'DatumUhrzeit'};
y1=flowCSV{:,'Durchflusslm'};
z1=flowCSV{:,'SmoothedFlow'};
y2=rainanalysis{:,'CumulativeRainfallDepth'};
figure(3);
ax=gca;
yyaxis left
plot(x1,y1,'-b',x1,z1,'-g');
xlabel('Date and Time');
ylabel('Flow [l/min]');
yyaxis right
bar(x2,y2,'r');
ax.YDir = 'reverse';
title('Flow and Rainfall');
ylabel('Rainfall [mm]');
grid on % show grid on plot
datacursormode on % enable to display data value interactively in the plot
clearvars ax x* y* z* % clear temporary variables
댓글 수: 0
답변 (1개)
Birdman
2017년 11월 26일
You should write the necessary code under that figure definiton for x axis as follows:
set(gca,'XLim',[0 10]);%the limits are random
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!