.jpeg)
Issue with XTicks and XTickLabels in App Designer
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Adam Danz
on 1 May 2019
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
.jpeg)
0 Comments
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!