MATLAB不在子图

时间:2017-07-27 12:40:38

标签: matlab plot subplot

我正在绘制4个子图,由于某种原因,图2中没有出现前2个子图的x轴刻度标签(x轴标签应该是距日期时间的小时数)。

我的代码是:

figure
subplot(2,4,1)
plot(dateval,Height,'b','LineWidth',1)
datetick('x','HH:MM') %change the axis to time format
xlim([736886.619552373 736886.692032847]) %Limits
set(gca, 'FontName', 'Bookman','FontSize',7);
xlabel('Time','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman')
ylabel('GPS Height $[m]$','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman','Interpreter','latex')


subplot(2,4,2)
plot(dateval,Pressure,'b','LineWidth',1)
datetick('x','HH:MM') %change the axis to time format
xlim([736886.619552373 736886.692032847]) %Limits
xlabel('Time','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman')
ylabel('Sensor Pressure $[mb]$','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman','Interpreter','latex')
set(gca, 'FontName', 'Bookman','FontSize',7);


subplot(2,4,[5 6])
scatter(Pressure,Height,3,'b','*'); %Number is the size of dots
h=lsline;
set(h,'color','r','LineWidth',2);
R=corrcoef([Pressure,Height]);
Fit = polyfit(Pressure,Height,1);
ylabel('GPS Height $$[m]$$','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman','Interpreter','latex');
xlabel('Pressure $[mb]$','FontSize',7,'FontWeight','normal','Color','k','FontName','Bookman','Interpreter','latex');
xlim([1003 1015])
ylim([0 90])
set(gca, 'FontName', 'Bookman','FontSize',7);
box on

 subplot(2,4,[3,4,7,8])
image( imread('TripMap.jpg') );
set(gca,'xtick',[])
set(gca,'xticklabel',[])
set(gca,'ytick',[])
set(gca,'yticklabel',[])

图:

enter image description here

我错过了什么?

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试更改这两行的顺序:

datetick('x','HH:MM') %change the axis to time format
xlim([736886.619552373 736886.692032847]) %Limits

致:

xlim([736886.619552373 736886.692032847]) %Limits
datetick('x','HH:MM') %change the axis to time format