【问题标题】:plot hold on in GUI在 GUI 中绘制保持
【发布时间】:2018-01-19 21:16:49
【问题描述】:

我是 matlab 新手,需要一些关于 gui 的帮助。我有两个轴框(axes2 和 axes3),我使用复选标记在其中进行绘图。第一个复选框创建两个图:一个 (x1,y1) 在轴 2 中,第二个 (x1,ht) 在轴 3 中。第二个复选框还创建了两个图:axes2 中的一个 (x2,y2) 和axes3 中的第二个 (x2,ht2)。我想保留这些数字,所以如果我同时选中两个复选标记,axis2 和 axes3 都将包含两个图。但是,只有 axes2 有效。在 axes3 中仅显示连接到最后选择的复选标记的图。

请帮忙。代码如下:

function checkbox1_Callback(hObject, eventdata, handles)
 if get(handles.checkbox1,'Value')
 hold on;
 handles.hCbox1Plot = plot(x1,y1,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes2);
 hold on;
 handles.hCbox2Plot = plot(x1,ht,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes3);
 guidata(hObject,handles);  % do this to save the updated handles structure
 else
  if ~isempty(handles.hCbox1Plot);
     ~isempty(handles.hCbox2Plot);
      delete(handles.hCbox1Plot);
      delete(handles.hCbox2Plot);
  end
 end

function checkbox2_Callback(hObject, eventdata, handles)
 if get(handles.checkbox2,'Value')
 hold on;
 handles.hCbox3Plot = plot(x2,y2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes2);
 hold on;
 handles.hCbox4Plot = plot(x2,ht2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes3);
 guidata(hObject,handles);  % do this to save the updated handles structure
 else
  if ~isempty(handles.hCbox3Plot);
     ~isempty(handles.hCbox4Plot);
      delete(handles.hCbox3Plot);
      delete(handles.hCbox4Plot);
  end
 end

【问题讨论】:

    标签: matlab user-interface plot


    【解决方案1】:

    我修复了它:

    hold(handles.axes2, 'on')

    【讨论】:

      猜你喜欢
      • 2013-04-11
      • 1970-01-01
      • 2023-03-24
      • 2022-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多