Effacer les filtres
Effacer les filtres

How do I assign two separate grid on check boxes for two separate plots in a gui?

1 vue (au cours des 30 derniers jours)
Zalikatu Kamara
Zalikatu Kamara le 29 Nov 2018
Réponse apportée : Greg le 30 Nov 2018
This is my callback function for the first check box for plot which works fine on its own
a=get(hObject,'Value');
if a==1
grid on;
axes(handles.axes4)
else
axes(handles.axes4)
grid off;
end
But when I try and turn on the checkbox for the grid in plot 2 it turns the grid on and off for plot 1 , and then turns on and off if plot 2 this is my callback for checkbox 2
a=get(hObject,'Value');
if a==1
grid on;
axes(handles.axes2)
else
axes(handles.axes2)
grid off;
end

Réponses (1)

Greg
Greg le 30 Nov 2018
You're calling grid on before forcing the active axes, which means you're going to have very unreliable behavior. You did better with grid off, but the best implementation is to pass the axes handle into the grid call:
grid(handles.axes2,'on');

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by