Two x-axis one y-axis double line plot in MATLAB GUI, GUIDE

Dear Community,
I am trying to create a plot in Matlab GUI (GUIDE) that concists of two x-axis, one y-axis and two lines in one plot environment. The plot and code works flawless on its own but I am not able to receive the correct figures in the GUI-environment. The problem is that I cannot plot multiple axes in the GUI. The code I use, presented below, works without error messages but it only plot the second "copyobj", i.e. the first curve disappears and the axis is shown in the bottom instead of top as defined. However, you can see the other line behind the GUI-area, i.e. the GUIDE is plotting both curves but not in the same Axes-environment, and not simultaneously. How can I approach the task?
In the code, "plotName", consists of plotName=fullfile(folder,filename), hence "tmpaxes" is a cell of (2,1) with the different plots saved in its rows. Can it be that both lines are "normalized" when the second should be a character, similar to the axis
Kind Regards Andreas
h=openfig(plotName,'invisible');
set(get(handles.SP_axes, 'Parent'), 'HandleVisibility', 'on')
axes(handles.SP_axes)
ax = findobj(h,'type','axes');
print = handles.SP_axes;
xl = get(get(ax(1),'xlabel'),'string'); % line bottom
x2 = get(get(ax(2),'xlabel'),'string'); % line top
y1 = get(get(ax(2),'ylabel'),'string');
tmpaxes = findobj(h,'Type','axes');
cla(handles.SP_axes)
copyobj(allchild(tmpaxes(2)),handles.SP_axes);
xlabel(handles.SP_axes,xl)
ylabel(handles.SP_axes,y1)
handles.SP_axes2 = axes('Units', 'character');
set(handles.SP_axes2, 'Position',get(handles.SP_axes,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color', 'none',...
'XColor','r'); %position the new axis on the earlier existing axis
copyobj(allchild(tmpaxes(1)),handles.SP_axes2);
xlabel(handles.SP_axes,x2)

답변 (1개)

Andreas Dahlgren
Andreas Dahlgren 2017년 9월 15일

0 개 추천

Attached is a template of what I am trying to achieve in GUIDE environment
Best regards

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

제품

질문:

2017년 9월 15일

답변:

2017년 9월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by