【问题标题】:MATLAB don't show x tick labels on subplotsMATLAB 不在子图上显示 x 刻度标签
【发布时间】:2017-07-27 12:40:38
【问题描述】:

我正在绘制 4 个子图,由于某种原因,前 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',[])

图:

我错过了什么?

谢谢!!

【问题讨论】:

  • 可以加你的图吗?
  • 是的 - 我已经编辑了我的帖子
  • 如果你分别绘制这两个,它会绘制吗?如果它看起来正确,那么您可能只需要格式化您的刻度。否则,您的 xlim 可能会出问题。

标签: matlab plot subplot


【解决方案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

【讨论】:

  • 它对蜱有用!但是现在 xlim 命令不起作用
  • 更改为 datetick('x','HH:MM','keeplimits')
  • 在我这样做之后它工作并将两行移到“set(gca ..”行之后!谢谢
猜你喜欢
  • 1970-01-01
  • 2022-01-01
  • 1970-01-01
  • 2021-06-01
  • 2021-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多