-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporting uifigure #261
Comments
Figures created using App Designer or the There is no possible solution or workaround for uifigures until this changes. |
I think this last commit may have broken the ability to specify an individual axes to plot: with a new install of export_fig, you can run this to recreate: f = figure();
ax = axes();
plot(ax, 1:10, sin(1:10));
export_fig(ax, 'test.png') which gives you the error:
This seems to happen because there is no JavaFrame property for axes, and is fixed by either checking for the existence of Hope that helps, and thanks for maintaining such a great library. |
…le as input, rather than a figure handle
Fixed, please recheck |
All good - thanks! |
Thanks for the alert. |
On Nov 18, 2018 above I wrote "This is still the case as of R2018b", so why are you asking about 2018a?! export_fig does not work with uifigures (created by AppDesigner or the uifigure command), in any Matlab release. When this will change (if ever), I will post an update. |
What you can do, however, is to copy your uifigure into a "standard" figure-window in the background. Use the "copy object" command to copy the uifigure's children into the new figure. Export that copied figure as usual. Maybe some formatting is still required. |
I
I also found that "annotation" does not work. Very frustration after following the AppDesigner route. |
@MarvinILA how do yo do that? |
@alfredoqt that's pretty easy. Please find below my code. Of course you might have to do some adjustments for your case. % Convert UIFigure to normal figure
fig = figure('Units', app.YourPlot.Units, 'Position', app.YourPlot.Position, 'InnerPosition', app.YourPlot.InnerPosition, 'OuterPosition', app.YourPlot.OuterPosition);
% Set figure to be invisible
set(fig, 'MenuBar', 'none', 'ToolBar', 'none', 'Visible', 'off');
% Get figure axes
figAxes = axes(fig);
% Get all the children from the UIFigure
allChildren = app.YourPlot.Children;
% Copy all children to the new figure
copyobj(allChildren, figAxes)
% Set axes limits
figAxes.XLim = app.YourPlot.XLim;
figAxes.YLim = app.YourPlot.YLim;
figAxes.ZLim = app.YourPlot.ZLim;
% Modify the legend
lgndName = app.YourPlot.Legend.String;
lgd = legend(YourPlotsToAppearInTheLegend, lgndName);
lgd.Box = app.YourPlot.Legend.Box;
lgd.Location = app.YourPlot.Legend.Location;
lgd.FontSize = app.YourPlot.Legend.FontSize;
% Set axes labels
figAxes.YLabel.String = app.YourPlot.YLabel.String;
figAxes.YLabel.FontSize = app.YourPlot.YLabel.FontSize;
figAxes.XLabel.String = app.YourPlot.XLabel.String;
figAxes.XLabel.FontSize = app.YourPlot.XLabel.FontSize;
% Set title
figAxes.Title.String = app.YourPlot.Title.String;
figAxes.Title.FontSize = app.YourPlot.Title.FontSize;
% Honestly, I don't remeber why I set that color
fig.Color = [1 1 1];
% Export figure
export_fig(fig, biplotFNfull, '-pdf', '-png', '-eps', '-m5');
% Clean up
delete(fig) Note the following:
Good luck coding! |
@MarvinILA - that's a great idea. I'm sorry that I missed it when you first posted it earlier this year. I'll integrate it into |
Fixed. There are still a few limitations, but I expect them to affect only a very small percentage of users:
Thanks again, @MarvinILA ! Enjoy! |
Yair, might I suggest you add a note about the partial support for BTW, I'm experimenting with exporting those figures via webpage-to-pdf JS libraries (like https://github.com/niklasvh/html2canvas and https://github.com/MrRio/jsPDF), but I'm struggling with the limitations TMW keeps imposing on custom JS libraries (despite supposedly allowing them through At the moment one can use |
@Dev-iL - done |
Hi,
I am trying to use the export_fig code within the Matlab App Designer. I am trying to export the figure with the following code:
However, as I execute the code the following error is shown:
How can I run export_fig with uifigures?
Thanks a lot!
The text was updated successfully, but these errors were encountered: