フィルターのクリア

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 月 6 日
Ok, thank you
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 Center および File ExchangeMaintain 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