Kiran
Kiran

Reputation: 8538

Export only the plot into png in Matlab

I am trying to export only the plot excluding all the axes and the padding on each side of the plot in Matlab. I removed the axes using the command :

  set(gca, 'Visible','off');

Any idea how exclude the padding as well from the plot ?

Thanks

I am looking for an image after exporting the plot someething like this : enter image description here

What I am currently getting is :

enter image description here

Upvotes: 1

Views: 69

Answers (1)

nkjt
nkjt

Reputation: 7817

This should be enough (you may also need to change the figure background color):

axis off
set(gca,'Position',get(gca,'OuterPosition'));

Basically, the axis settings contain several different position values; Position is the bounding box around the actual graph, TightInset the bounding box which also incorporates the axis labels etc., OuterPosition the outermost. Setting the innermost Position to equal OuterPosition just expands your graph to fill the plotting space.

Upvotes: 3

Related Questions