Saveas figure (UIAxes) from app designer to a specific folder left and right plots
10 次查看(过去 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
0 个评论
采纳的回答
Adam Danz
2021-6-4
编辑:Adam Danz
2021-6-6
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!