Data is not contained within x-axis limits

1 view (last 30 days)
Andy Wang
Andy Wang on 19 Feb 2021
Edited: Adam Danz on 22 Feb 2021
All,
So essentially I have an issue where if I zoom into a plot through a scroll wheel or a box, some of the data displayed extends past the x-axis limits as shown in the picture below.
The plot is located within an application I am building using App Designer. Do I need to reset the xlim or something within a callback function?
Insights would be greatly appreciated.
Thanks.
  1 Comment
Mario Malic
Mario Malic on 20 Feb 2021
This shouldn't happen, it's a bug, maybe you could contact customer service.
When it does happen, try resizing the app. Maybe you could create a button that triggers drawnow and see if it helps.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 20 Feb 2021
Edited: Adam Danz on 22 Feb 2021
Get the handle to the line object and look at the Clipping property. If it's set to 'off' figure out what part of the code changed it from the default 'on' and fix it or just set it to on.
If clipping wasn't the issue, check that there isn't an invisible axis that hosts the line object. Get the line object handle and use ax=ancestor(h,'axes') to get the parent axes of the line object. Then delete the axes using delete(ax). If you still see the axes then you know you've just deleted an invisible axes with a larger extent than the visible axes.
If you've ruled out the clipping problem and invisible axes, contact tech support: Contact Us - MATLAB & Simulink
Example of clipping issue:
x = 0 : .01 : 10;
y = rand(size(x));
h = plot(x,y);
ylim([-5,5])
h.Clipping = 'off';
xlim([2,8])

Categories

Find more on Graphics Object Programming 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!