exporting figures as vector graphics without white spacing

Hello
I am
(1) trying to reduce the amount of white space around my figure when it is saved in matlab
(2) I am trying to export it as vector graphics
My code , generalized to a simple example, is as follows:
figure(figureNum);figureNum=figureNum+1;
x=1;
m=[1,2];
bar(x,m); hold on %mean on the y-axis
set(gca,'fontsize',fontSize);
I tried
exportgraphics(gca,'myplot.png','Resolution',300) and it did not work.

Answers (1)

x=1;
m=[1,2];
bar(x,m);
exportgraphics(gcf,'myplot.png','Resolution',300)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Asked:

on 7 Apr 2022

Answered:

on 7 Apr 2022

Community Treasure Hunt

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

Start Hunting!