how to always display “labels” on axis X

前端 未结 2 933
长情又很酷
长情又很酷 2021-01-22 15:15

If I zoom several time graph all labels from axis X disapear (go away) and there are no visible axis X labels so it is not possible to understand the part of graph where am I.

相关标签:
2条回答
  • 2021-01-22 15:32

    it depends, are you manually setting the tick marks yourself ('XTick' and 'XTickLabel' axis properties)?

    Try this simple example

    plot(sin(1:10), 'o-')
    

    without changing anything, you can zoom as much as you want, and the tick labels will always be visible


    EDIT

    The root cause of the problem is the same as the one raised in your other question, datetick function will manually set the tick labels, thus disabling automatic update on zoom/pan.

    The good news is there are already submissions on FEX that tries to solve this exact problem with DATETICK

    0 讨论(0)
  • 2021-01-22 15:50

    I run into the same problem even on the new version of MATLAB (r2014). MATLAB does not display sufficient x-axis tick labels as you zoom-in. After several experiments I found the following workaround. Following is a plot before implementing the solution. MATLAB displays only three XTick labels on the x-axis even though there is sufficient space for more (there are often even less labels as you zoom in more). After zooming-in ML displays only three XTick labels on the x-axis even though there is sufficient space for more.

    Suspecting that MATLAB thinks that it does not have sufficient space to display more labels, a workaround can be to rotate the labels. To do that, after you issue the plot commands, e.g.

    plot(tsX);
    hold on;
    plot(tsY);
    plot(tsZ);
    

    add the following command

    set(gca,'XTickLabelRotation',90);
    

    Now MATLAB plots with more labels After rotating the X Tick labels MATLAB plots more labels as you zoom-in.

    I am going to report this as a bug to the MATLAB guys.

    0 讨论(0)
提交回复
热议问题