フィルターのクリア

Issue with XTicks and XTickLabels in App Designer

20 ビュー (過去 30 日間)
Hawki005
Hawki005 2019 年 5 月 1 日
回答済み: Adam Danz 2019 年 5 月 1 日
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?
Capture.JPG
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';

採用された回答

Adam Danz
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
190501 091200-DisplayMajorMinorGridLinesExample_01.png (560×420).jpg

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by