Borrar filtros
Borrar filtros

How can I draw a line over a 2D surface plot in an app?

2 visualizaciones (últimos 30 días)
I'm trying to draw a line on this plot when a function is triggered:
The function is below, it includes the creation of the surface plot above:
% Value changed function: NSLineSelectorSpinner
function NSLineSelectorSpinnerValueChanged(app, event)
value = app.NSLineSelectorSpinner.Value;
Bat = mvf_plane([app.minc,app.mdec,app.m],app.Ba_mag,app.Ba_inc,app.Ba_dec,30,1,app.alt);
Max = max(Bat,[],'all');
Min = min(Bat,[],'all');
plot(app.UIAxes,Bat(:,value))
xlim(app.UIAxes,[0 60]);
ylim(app.UIAxes,[Min Max]);
ytickformat(app.UIAxes,'%g');
ax = app.UIAxes;
ax.YAxis.Exponent = 0;
surf(app.UIAxes2,Bat);
ylim(app.UIAxes2, [0 60]);
xlim(app.UIAxes2, [0 60]);
view(app.UIAxes2,2);
app.UIAxes2.PositionConstraint = 'outerposition';
When the user changes the value on a spinner, a matrix ("Bat") is recalculated and the profile graph (UIAxes) and surface plot (UIAxes2) are remade. I would like to draw a vertical line along the y-axis of the surface plot at whatever "value" currently is ("value" will be along the x-axis). This is meant to just highlight whichever line is selected by the spinner without having the app open up another figure.
Thank you.

Respuesta aceptada

SALAH ALRABEEI
SALAH ALRABEEI el 18 de Jun. de 2021
yline(put the value)
  2 comentarios
Joshua Mitchell
Joshua Mitchell el 18 de Jun. de 2021
That worked! I went with:
xline(app.UIAxes2,value,'Color','red','LineStyle','--','LineWidth',1.5);
Do you know if xline will work on a 3D plot as well?
SALAH ALRABEEI
SALAH ALRABEEI el 18 de Jun. de 2021
yes sure, it works along the x axis.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by