Save current figure without axis, axis label and other border areas.

조회 수: 53 (최근 30일)
ac_bm_mat
ac_bm_mat 2022년 5월 3일
편집: ac_bm_mat 2022년 5월 3일
How to save current figure without axis, axis label and other white margin spaces around the figure. I don't have direct access to the matrix which is being plotted. So I want to use something like this:
saveas(gcf, "xyz.png");
but additional spaces and axis labels are also coming into it. I want these to be removed. I want to save only the actual plot area.

채택된 답변

Matt J
Matt J 2022년 5월 3일
편집: Matt J 2022년 5월 3일
I don't have direct access to the matrix which is being plotted.
Yes, you do. The axes children will always contain the data that is being plotted. So, the easiest would be to replot the figure with,
axis off
export_graphics(gcf, "xyz.png")
A less graceful alternative would be to use export_fig, downloadable from,
which let's you specify the amount of cropping of the exported image. Choose the cropping just right and you will clip away the axis markings.
  댓글 수: 3
Matt J
Matt J 2022년 5월 3일
편집: Matt J 2022년 5월 3일
With which of the two solutions I mentioned? With export_fig, all white space will be removed by default and you have input switches to adjust the amount of cropping if you wish.
ac_bm_mat
ac_bm_mat 2022년 5월 3일
The export_fig from github is working fine. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by