Multiple plots using same axis in Matlab

2 views (last 30 days)
akshay raj
akshay raj on 2 Feb 2015
Edited: per isakson on 2 Feb 2015
I have a pop-up menu (used GUIDE to create it.) which calls 3 functions
  1. first function gives out a scatter plot of 14x14x14
  2. second function plots a bar graph of 4x1 (dynamic data)
  3. third function plots an Mx14 (dynamic data)
the thing all these use the same axes
axes(handles.someName).
I tried putting axes focus on every switch statement
function plot_options_popup_Callback(hObject, eventdata, handles)
str = get(hObject, 'String');
val = get(hObject, 'Value');
switch str{val};
case 'Final Reading'
YesNo = evalin('base','exist(''eeg_output_1d'',''var'')');
axes(handles.eeg_final)
if(YesNo == 1)
plot(evalin('base','eeg_output_1d'));
else
return;
end
case 'Activation Plot'
axes(handles.eeg_final)
activation
case 'Emotion State'
axes(handles.eeg_final)
emo_Callback
end
And when I change the option to a new one, the focus changes to the dynamic data which is continuously plotting.
Is there any way I could ask to GUI to stick to the thing what I want to and plot the dynamic data in the background?
Thanks in advance.

Answers (1)

per isakson
per isakson on 2 Feb 2015
Edited: per isakson on 2 Feb 2015
Yes, provide the axes-handle in the call to scatter3 ... instead of setting the current axes. Doc says:
scatter3(ax,___) plots into the axes specified by ax instead of into the
current axes (gca). The ax option can precede any of the input argument
combinations in the previous syntaxes.
and
plot(ax,___) plots into the axes specified by ax instead of into
the current axes (gca). The option, ax can precede any of the input
combinations in the previous syntaxes.
and
bar(ax,___) plots into the axes specified by ax instead of into the
current axes (gca). The option ax can precede any of the input
argument combinations in the previous syntaxes.
  2 Comments
akshay raj
akshay raj on 2 Feb 2015
but then they are continuous data wouldn't that change its focus from one function to other?
per isakson
per isakson on 2 Feb 2015
Edited: per isakson on 2 Feb 2015
Not sure I understand or rather I don't understand. Axes-handles are unique in a Matlab session. Make an experiment!

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks 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!