Replotting a 2D graph on a 3D surface keeps all 3 axes
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Using app designer, I have one UIAxis that allows the user to switch between a 2D line plot and a 3D surface plot. When switching from the 3D plot to the 2D plot the z-axis remains which it is not supposed to. The user should be able to switch between as much as they want.
cla(app.UIAxes);
if app.DButton.Value == 1 % 2D check selected
plot(app.UIAxes,app.xaxis,app.yaxis) % plot 2 graph
app.graph = app.UIAxes.Children;
else % else 3D check selected
[X,Y] = meshgrid(app.xaxis,app.yaxis);
[Z] = meshgrid(app.zaxis);
surf(app.UIAxes,X,Y,Z) % 3D surface plot
end
I'm using cla(app.UIAxes) to reset the axis every time the radiobutton is changed but for some reason the plot is keeping the z-axis even though the code has plot(x,y).
It's supposed to be:
What is actually being plot:
Any help would be appreciated.
0 Commenti
Risposta accettata
Dave B
il 17 Mar 2022
Modificato: Dave B
il 17 Mar 2022
cla doesn't reset the view.
Here are some options:
Set the view explicitly: view(app.UIAxes, 2)
Call cla with the reset flag, which will reset the axes to its original state (including getting rid of the labels and other things you've done to configure it): cla(app.UIAxes ,'reset')
Note the presence/absence of the grid in the examples below, surf turns on the grid (if you haven't set it explicitly elsewhere), cla doesn't turn it off, but cla('reset') does.
figure;
surf(peaks);xlabel('x');cla
figure;
surf(peaks);xlabel('x');cla('reset')
figure;
surf(peaks);xlabel('x');cla;view(2)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!