How do I stop exportgraphics from adding a border
Hi Everyone
I’m using Matlab 2024b and have found an oddity.
If I load an image and then export it again exportgraphics seem to add a white border
In its simplest form…
fig = figure();
im = imread(‘peppers.png’);
imshow(im)
exportgraphics(gca,’exportplot.jpg’);
If you compare peppers.png with the exported version then you can see a pixel wide border has been added
I’ve tried
set(gca, ‘color’, ‘none’);
axis off
exportgraphics(gca,’plot2.jpg’,’BackgroundColor’,’none’)
but none of these seem to make any difference. What’s annoying is that I’m also using exportgraphics to generate animated gifs but the white margin appears around those too. This really shows up on the black background that I’m using.
Any suggestions on how to eliminate this?Hi Everyone
I’m using Matlab 2024b and have found an oddity.
If I load an image and then export it again exportgraphics seem to add a white border
In its simplest form…
fig = figure();
im = imread(‘peppers.png’);
imshow(im)
exportgraphics(gca,’exportplot.jpg’);
If you compare peppers.png with the exported version then you can see a pixel wide border has been added
I’ve tried
set(gca, ‘color’, ‘none’);
axis off
exportgraphics(gca,’plot2.jpg’,’BackgroundColor’,’none’)
but none of these seem to make any difference. What’s annoying is that I’m also using exportgraphics to generate animated gifs but the white margin appears around those too. This really shows up on the black background that I’m using.
Any suggestions on how to eliminate this? Hi Everyone
I’m using Matlab 2024b and have found an oddity.
If I load an image and then export it again exportgraphics seem to add a white border
In its simplest form…
fig = figure();
im = imread(‘peppers.png’);
imshow(im)
exportgraphics(gca,’exportplot.jpg’);
If you compare peppers.png with the exported version then you can see a pixel wide border has been added
I’ve tried
set(gca, ‘color’, ‘none’);
axis off
exportgraphics(gca,’plot2.jpg’,’BackgroundColor’,’none’)
but none of these seem to make any difference. What’s annoying is that I’m also using exportgraphics to generate animated gifs but the white margin appears around those too. This really shows up on the black background that I’m using.
Any suggestions on how to eliminate this? exportgraphics, margins, border MATLAB Answers — New Questions









