Matlab Gui axes problem

2 次查看(过去 30 天)
Itziar Uzqueda
Itziar Uzqueda 2017-5-11
Hi everybody,
I have a problem related to the axes in matlab Gui. I have 3 axes and I don't know why two of them have their 'Xaxis' linked. I don't have linkaxes function in any of them. I think the problem is somewhere in this part of the code. It would be great if any of you could help me.
function showSupportPhasesPlot(handles)
zoom out;
zoom off;
%%%%SENSOR INERCIAL DERECHO
timeMTw = handles.analysisData.timeMTw;
%accelMTw = handles.analysisData.accelMTw;
OrientXMTw = handles.analysisData.OrientXMTw;
OrientYMTw = handles.analysisData.OrientYMTw;
OrientZMTw = handles.analysisData.OrientZMTw;
stepLimitsTime = handles.analysisData.stepLimitsTimeMTw;
fileMTw = handles.analysisData.file;
axes(handles.axes1);
cla(handles.axes1);
% hl = line(timeMTw, accelMTw(:,1));
% set(hl, 'Color', 'm', 'LineWidth', 1);
% hl = line(timeMTw, accelMTw(:,2));
% set(hl, 'Color', 'c', 'LineWidth', 1);
% hl = line(timeMTw, accelMTw(:,3));
% set(hl, 'Color', 'k', 'LineWidth', 1);
hl = line(timeMTw, OrientXMTw);
set(hl, 'Color', 'r', 'LineWidth', 1);
hl = line(timeMTw, OrientYMTw);
set(hl, 'Color', 'g', 'LineWidth', 1);
hl = line(timeMTw, OrientZMTw);
set(hl, 'Color', 'b', 'LineWidth', 1);
yLim = get(gca, 'YLim');
stepHandles = zeros(size(stepLimitsTime,1),1);
for k=1:size(stepLimitsTime,1)
stepStart = stepLimitsTime(k);
hlStart = line([stepStart stepStart], yLim);
set(hlStart, 'Color', [0.3 0.3 0.3], 'LineStyle', '--', 'LineWidth', 1);
stepHandles(k,:) = [hlStart];
end
handles.stepHandles = stepHandles;
str = strcat('Inercial derecho - ',fileMTw);
set(get(handles.axes1, 'title'), 'string', str);
set(handles.axes1, 'UiContextMenu', handles.axesMenu, 'XLim', [timeMTw(1) timeMTw(end)]);
%set(handles.axes1, 'UiContextMenu', handles.axesMenu, 'XLimMode', 'auto');
axes(handles.axes1);
%guidata(gcf, handles);
%%%%SENSOR INERCIAL IZQUIERDO
timeMTw2 = handles.analysisData.timeMTw2;
%accelMTw2 = handles.analysisData.accelMTw2;
OrientXMTw2 = handles.analysisData.OrientXMTw2;
OrientYMTw2 = handles.analysisData.OrientYMTw2;
OrientZMTw2 = handles.analysisData.OrientZMTw2;
stepLimitsTime2 = handles.analysisData.stepLimitsTimeMTw2;
fileMTw2 = handles.analysisData.file2;
axes(handles.axes3);
cla(handles.axes3);
% hl = line(timeMTw2, accelMTw2(:,1));
% set(hl, 'Color', 'm', 'LineWidth', 1);
% hl = line(timeMTw2, accelMTw2(:,2));
% set(hl, 'Color', 'c', 'LineWidth', 1);
% hl = line(timeMTw2, accelMTw2(:,3));
% set(hl, 'Color', 'k', 'LineWidth', 1);
h2 = line(timeMTw2, OrientXMTw2);
set(h2, 'Color', 'r', 'LineWidth', 1);
h2 = line(timeMTw2, OrientYMTw2);
set(h2, 'Color', 'g', 'LineWidth', 1);
h2 = line(timeMTw2, OrientZMTw2);
set(h2, 'Color', 'b', 'LineWidth', 1);
yLim2 = get(gca, 'YLim');
stepHandles2 = zeros(size(stepLimitsTime2,1),1);
for k=1:size(stepLimitsTime2,1)
stepStart2 = stepLimitsTime2(k);
h2Start2 = line([stepStart2 stepStart2], yLim2);
set(h2Start2, 'Color', [0.3 0.3 0.3], 'LineStyle', '--', 'LineWidth', 1);
stepHandles2(k,:) = [h2Start2];
end
handles.stepHandles2 = stepHandles2;
str = strcat('Inercial izquierdo - ',fileMTw2);
set(get(handles.axes3, 'title'), 'string', str);
set(handles.axes3, 'UiContextMenu', handles.axesMenu, 'XLim', [timeMTw2(1) timeMTw2(end)]);
axes(handles.axes3);
%guidata(gcf, handles);
%%%%%SENSOR DE ULTRASONIDO
distancia = handles.analysisData.distancia;
samples = handles.analysisData.samples;
stepLimitsTime3 = handles.analysisData.stepLimitsTimeMTw3;
fileMTw3 = handles.analysisData.file3;
% samples=1:size(distancia);
axes(handles.axes2);
cla(handles.axes2);
ts=0.01;
time=samples*ts; %sampling time
h3 = line(time, distancia);
set(h3, 'Color', 'b', 'LineWidth', 1);
yLim3 = get(gca, 'YLim');
stepHandles3 = zeros(size(stepLimitsTime3,1),1);
for k=1:size(stepLimitsTime3,1)
stepStart3 = stepLimitsTime3(k);
h3Start3 = line([stepStart3 stepStart3], yLim3);
set(h3Start3, 'Color', [0.3 0.3 0.3], 'LineStyle', '--', 'LineWidth', 1);
stepHandles3(k,:) = [h3Start3];
end
% plot(time,distancia);
str = strcat('Ultrasonido - ',fileMTw3);
set(get(handles.axes2, 'title'), 'string',str);
set(handles.axes2, 'UiContextMenu', handles.axesMenu, 'XLim', [time(1) time(end)]);
%set(handles.axes1, 'UiContextMenu', handles.axesMenu, 'XLimMode', 'auto');
% zoom off;
% pan off;
% rotate3d off;
% datacursormode off;
% brush off;
axes(handles.axes2);
set(gcf, 'WindowButtonDownFcn', 'StepAnalysis(''supportButtonDown'',guidata(gcf))');
guidata(gcf, handles);
  4 个评论
Stephen23
Stephen23 2017-5-11
编辑:Stephen23 2017-5-11
I second Adam's comment. Your code would be simpler and much more reliable by always passing and using explicit graphics handles. Reliable code never uses gca, gcf, or the like, and does not rely on bringing some graphics object into focus. Those commands are just asking for trouble, exactly as you are experiencing now.
Itziar Uzqueda
Itziar Uzqueda 2017-5-11
Yes, I have followed your advice but it still doesn't work. I don't know what else can I do.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by