Removing the grey margin of a plot

126 ビュー (過去 30 日間)
hamed
hamed 2017 年 11 月 27 日
コメント済み: hamed 2017 年 12 月 1 日
Hi I'm doing an image analysis using matlab. I have a figure that I need to remove the grey margin and axes while keeping the original white plot area size constant and then save it as png. You can see the saved original png which I need to remove the axes and the margin but keeping the plot area size constant. p.s. I'm using R2017a version.

採用された回答

KSSV
KSSV 2017 年 11 月 27 日
plot(peaks)
title('Plot of Peaks Function')
axis off
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
Now save them using saveas
  1 件のコメント
hamed
hamed 2017 年 12 月 1 日
I faced another problem. This code still keeps the margin due to x and y axis even though I removed the axis. You can see that in the attached figure. How to remove that white margin too?

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 11 月 27 日
img = imread('fig2.png');
im2 = img;
mask = repmat(all(im2 < 240,3),1,1,3);
im2(mask) = 255;
  1 件のコメント
hamed
hamed 2017 年 11 月 27 日
Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by