How to plot a graph in MATLAB - Rainfall on secondary axis (inverted i.e, upside down), Simulated results in line and Observed in dotted on primary axis.
10 次查看(过去 30 天)
显示 更早的评论
I have rainfall data. Simulated soil moisture and observed soil moisture. I want to plot it in MATLAB, with rainfall data on secondary Y-axis (Inverted), Simulated and Observed soil data on primary axis. X axis will show number of days, while primary and secondary axis will show Soil moisture and rainfall depth.
回答(1 个)
Navid J
2017-5-18
编辑:Navid J
2017-5-18
figure1 = figure('position', [0, 0, plotwidth, plotheight]);
ax1 = axes('Parent',figure1);
hold(ax1,'on');
plot(date,TS1,'color',[0 0 0]);
plot(date,TS2,'color',[0 0 1]);
ylim([0 0.7])
xlim([datenum('2016/05/1') datenum('2016/10/1')])
xlabel('Date')
ylabel('Soil Moisture (cm^3/cm^3)')
legend('TS 1', 'TS 2','Location', 'Northeast');
datetick('x','mmm','keeplimits')
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
set(ax2,'Ydir','reverse')
line(x,p,'Parent',ax2,'color',[1 1 1])
set(ax2,'Color','none','XAxisLocation','top','XTickLabel',...
{'','','','','',''},'YAxisLocation','right');
ylim([0 90])
xlim([datenum('2016/05/1') datenum('2016/10/1')])
xlabel('')
ylabel('Rainfall (mm)')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!