Issue with XTicks and XTickLabels in App Designer
조회 수: 20 (최근 30일)
이전 댓글 표시
I have a plot in app designer that uses a UI Axis. The data goes to 32 hours but I would like to limit the x axis (Time in hours) range to 24 hours and then label the XTicks every 4 hours. However, with the XLim working to limit to 24 hours, the distance between Ticks is still 5 hours, but with the correct Tick Labels. Am I missing something?
This is my axis manipulation code:
app.UIAxes2.XAxisLocation = 'origin';
app.UIAxes2.YAxisLocation = 'origin';
app.UIAxes2.XMinorGrid = 'on';
app.UIAxes2.YMinorGrid = 'on';
app.UIAxes2.XGrid = 'on';
app.UIAxes2.YGrid = 'on';
app.UIAxes2.XLimMode = 'manual';
app.UIAxes2.XLim = [0 24];
app.UIAxes2.XTickMode = 'manual';
app.UIAxes2.XTick = ([0 4 8 12 16 20 24]);
app.UIAxes2.XTickLabelMode = 'manual';
app.UIAxes2.XTickLabel = [0 4 8 12 16 20 24];
app.UIAxes2.YLimMode = 'auto';
app.UIAxes2.YTickMode = 'auto';
댓글 수: 0
채택된 답변
Adam Danz
2019년 5월 1일
Your code is fine. I think you're assuming the tick interval is 5 hours because there are 5 minor grid lines in each interval. If that's the case, you shouldn't assume the minor ticks are at 1-hr intervals.
Below is an example in the documentation where the minor grids contain 5 segments between ticks. To be certain that your ticks are correct, plot some data at known coordinates and make sure they align with your ticks.
plot(4,1,'r*') % on tick x=4
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!