Change plot in single axes on click (GUIDE)
显示 更早的评论
Hi, I have a function that generates multiple plots (15 or so). I am able to display all of them (their titles) in a listbox. What I would like to do is to display the plot upon clicking on a proper title in a listbox.
\\This is part of a previous callback
set(handles.figures_list_tag,'string',fieldnames(handles.allfigures));
handles.fieldnames=fieldnames(handles.allfigures);
guidata(hObject,handles)
% --- Executes on selection change in figures_list_tag.
function figures_list_tag_Callback(hObject, eventdata, handles)
selected_figure_index=get(hObject,'Value');
figure_array=cellstr(get(hObject,'String'));
selected_figure=getfield(handles.allfigures,handles.fieldnames{selected_figure_index});
handles.figure_tag;
cla;
hold on
set(handles.figure_tag,'CurrentAxes',findobj(handles.allfigures,selected_figure))
guidata(hObject,handles)
Anyhow, this doesn't work, but just to give you an idea what I have so far. Any advice how to do this? Thanks in advance!
6 个评论
Geoff Hayes
2018-6-18
luiv1616 - how do you expect to show the plot in the axes? Have you already plotted it but have chosen to hide the plot until you need to show it? Please clarify...
luiv1616
2018-6-18
Geoff Hayes
2018-6-18
luiv1616 - so you have 15 functions that have been plotted on 15 figures and you can grab a list of the names of each figure which you show in your GUI. Your GUI also has an axes which you wish to "copy" or "show" the plot from figure x. For example, if the user selects the second figure from the list, then you want to copy the plot from the second figure to your GUI axes. is that correct?
If the above is correct, can you clarify why you want to do this. Why plot the 15 functions on 15 figures? Why not just plot them within the axes and hide or show them as needed?
luiv1616
2018-6-19
Geoff Hayes
2018-6-19
Whenever you call plot, it returns a handle to the plot graphics object. i.e.
hPlot = plot(handles.axes1, x, y);
You can then show or hide the plot with the handle
set(hPlot, 'Visible', 'off');
or
set(hPlot, 'Visible', 'on');
So draw all of your 15 functions to the axes of your GUI. You should be able to set the default visibility state to off for each one. And you can save all of these 15 graphic object handles to the handles structure of your GUI so that you can later access them. For example,
hPlot1 = plot(handles.axes1, x, y, 'Visible', 'off');
hPlot2 = ....
handles.plotHandles = [hPlot1 hPlot2 ...];
guidata(handles);
luiv1616
2018-6-20
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!