【发布时间】:2018-01-28 08:05:30
【问题描述】:
我是 matlab gui 的新手,正在开发我的第一个程序。我有大约 10 个需要绘制的数据集,但只有在通过复选框选择激活时才会在轴 1 和轴 2 中生成两个图。有时我只想随机激活一些,但我需要那些激活的传奇。而且我需要在取消单击复选框后再次消失图例。我已经使情节按我的意愿行事,但我不知道如何处理图例。当复选框被激活时,相同的图例(如温度)应该出现在轴 1 和轴 2 中。 到目前为止,这是我的代码:
function checkbox1_Callback(hObject, eventdata, handles)
if get(handles.checkbox1,'Value')
hold( handles.axes1, 'on' )
handles.plotCDS1 = plot(dataS1(:,1),NormCdS1(:,1),'LineWidth',2,'Color', [0 0 0],'parent',handles.axes1);
hold( handles.axes2, 'on' )
handles.plotHTS1 = plot(dataS1(:,1),dataS1(:,3),'LineWidth',2,'Color', [0 0 0],'parent',handles.axes2);
guidata(hObject,handles); % do this to save the updated handles structure
else
if ~isempty(handles.plotCDS1);
delete(handles.plotCDS1);
~isempty(handles.plotHTS1);
delete(handles.plotHTS1);
end
end
和第二个复选框:
function checkbox2_Callback(hObject, eventdata, handles)
if get(handles.checkbox2,'Value')
hold( handles.axes1, 'on' )
handles.plotCDS2 = plot(dataS2(:,1),NormCdS2(:,1),'LineWidth',2,'Color', [1 0 0],'parent',handles.axes1);
hold( handles.axes2, 'on' )
handles.plotHTS2 = plot(dataS2(:,1),dataS2(:,3),'LineWidth',2,'Color', [1 0 0],'parent',handles.axes2);
guidata(hObject,handles); % do this to save the updated handles structure
else
if ~isempty(handles.plotCDS2);
delete(handles.plotCDS2);
~isempty(handles.plotHTS2);
delete(handles.plotHTS2);
end
end
然后我还有 8 个复选框。请帮忙...谢谢
【问题讨论】:
标签: matlab plot matlab-guide