- drawnow- https://www.mathworks.com/help/matlab/ref/drawnow.html?searchHighlight=drawnow&s_tid=srchtitle_support_results_1_drawnow
- ylim- https://www.mathworks.com/help/matlab/ref/ylim.html?searchHighlight=ylim&s_tid=srchtitle_support_results_1_ylim
- ytick- https://www.mathworks.com/help/matlab/ref/yticks.html?searchHighlight=ytick&s_tid=srchtitle_support_results_1_ytick
- linspace- https://www.mathworks.com/help/matlab/ref/linspace.html?searchHighlight=linspace&s_tid=srchtitle_support_results_1_linspace
Issue with slanted y-axis ticks when using UIAxes component in app designer.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm attempting to create a MATLAB app that displays a 2D plot but I'm intermittently having issues with the Y-axis tick when inserting a UIAxes plot.
It only seems to happen for certain combinations of x and y data. My guess is it has something to do with how the UIAxes supports all 3 axis. For some reason there isn't an option to lock the UIAxes into a 2d format what I can tell.
I've tried programmatically resetting the viewing angle after plotting but that doesn't seem to fix it.
Here is the code I'm using to plot:
plot(Ax,X,Y,'-k');
view(Ax, 0, 90);
grid(Ax,'minor');
Any help would be much appreciated.
0 Kommentare
Akzeptierte Antwort
Simar
am 14 Mai 2024
Bearbeitet: Simar
am 15 Mai 2024
Hi John,
As per my understanding you are trying to maintain 2D perspective for plot in MATLAB App (using UIAxes), but there are challenges with the Y-axis ticks under specific conditions The command “view(Ax, 0, 90)”; aims to present the plot in 2D by adjusting the viewing angle, which is an appropriate method. If problem persists following solutions can help in troubleshooting and potentially solving the issue:
1. Ensure Correct Viewing Angle: Use of view(Ax, 0, 90) is correct for setting 2D view. However, make sure this command is executed after the plot is rendered. This is because some plotting commands may reset the camera view, potentially overriding the specified view settings.
2. Axis Limits and Ticks: If issue is specifically with Y-axis ticks, consider setting Y-axis limits and ticks explicitly to ensure they are displayed as expected. For example:
ylim(Ax, [minY maxY]); % Set Y-axis limits
yticks(Ax, linspace(minY, maxY, numTicks)); % Set Y-axis ticks
Adjust minY, maxY, and numTicks as needed for your data.
3. Force Redraw: Forcing the UI to redraw can help. After setting your view, you might want to use “drawnow”; to ensure UI updates with specified settings.
4. Debugging: Try isolating the issue that only includes the UIAxes and the plotting functionality. This can help determine if the issue is with data, the plotting commands, or interference from other parts of the app.
Here is a refined snippet incorporating some of the suggestions:
plot(Ax, X, Y, '-k');
grid(Ax, 'minor');
ylim(Ax, [min(Y) max(Y)]); % Assuming Y is your data vector
yticks(Ax, linspace(min(Y), max(Y), 10)); % Example: 10 ticks across the Y range
view(Ax, 0, 90); % Ensure this is after plotting commands
drawnow; % Force the UI to update
If problem is specific (only occurs with certain data sets or under specific conditions), it might be helpful to examine the data or conditions under which issue arises more closely. Check combinations of X and Y data that triggers this behaviour, such as large or small values, NaNs that could be affecting default axis limits and ticks.
Please refer to the following documentation links-
Hope it helps!
Best Regards,
Simar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!