필터 지우기
필터 지우기

Saveas figure (UIAxes) from app designer to a specific folder left and right plots

조회 수: 18 (최근 30일)
I'm traying to save a figure (UIAxes) with left and right axis from app designer to a specific foder by using the following code existing in this link:
Then i have this error : "Undefined function 'copyUIAxes' for input arguments of type 'matlab.ui.control.UIAxes' "
I'm using matlab 2016b.
% Create yyaxis plot within uiaxes
fig = uifigure();
ax = uiaxes(fig);
yyaxis(ax, 'left')
plot(ax, 1:5, rand(1,5), '-')
ylabel(ax, 'left')
yyaxis(ax, 'right')
plot(ax, 1:.2:5, rand(1,21), 'o')
ylabel(ax, 'right')
xlabel(ax, 'x axis')
title(ax, 'Title')
% Copy left and right axes to the same figure
newFig = figure;
yyaxis(ax, 'left')
axLeft = copyUIAxes(ax, newFig);
yyaxis(ax, 'right')
axRight = copyUIAxes(ax, newFig);
% Make some changes to the right axes
axRight.axes.Color = 'none'; % make transparent
axRight.axes.XTick = []; % remove duplicate x-ticks
axRight.axes.XLabel = []; % remove duplicate x-label
axRight.axes.Title = []; % remove duplicate title

채택된 답변

Adam Danz
Adam Danz 2021년 6월 4일
편집: Adam Danz 2021년 6월 6일
You must be referring to this answer which contains a link to the function on the file exchange.
Make sure the file is on your Matlab path. Also make sure you're using version 4.0.0 or later to copy yyaxis plots.
Update
After viewing your code, I see where you're using the function incorrectly. You're copying the left and right axes separately. copyUIAxes copies both the left and right axes. So you're actually producing two copies on the same figure.
Here's the correction
% Create yyaxis plot within uiaxes
fig = uifigure();
ax = uiaxes(fig);
yyaxis(ax, 'left')
plot(ax, 1:5, rand(1,5), '-')
ylabel(ax, 'left')
yyaxis(ax, 'right')
plot(ax, 1:.2:5, rand(1,21), 'o')
ylabel(ax, 'right')
xlabel(ax, 'x axis')
title(ax, 'Title')
% Copy left and right axes to the same figure
newFig = figure;
axLeft = copyUIAxes(ax, newFig);
  댓글 수: 7
amakoba yim
amakoba yim 2021년 6월 8일
It works well.
I'm sorry I didn't see your answer.
Thank you very much for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Maintain or Transition figure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by