Azzera filtri
Azzera filtri

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

18 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Adam Danz
Adam Danz il 4 Giu 2021
Modificato: Adam Danz il 6 Giu 2021
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 Commenti
amakoba yim
amakoba yim il 8 Giu 2021
It works well.
I'm sorry I didn't see your answer.
Thank you very much for your help.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Maintain or Transition figure-Based Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by