How do I make a full page figure publish?

조회 수: 55 (최근 30일)
Isaac Gruver
Isaac Gruver 2019년 4월 17일
편집: Rahul 2024년 9월 5일
I'm trying to get a graph to publish on a full page by itself, but I can't figure out how do it. Whenever I try increasing the figure size it stops at the top edge of my screen, and then publishes what's on my screen, not what I coded.
I want the graph that comes from this to take up its own entire publication page in pdf form.
x=[.062 .122 .182 .241 .303 .364 .425 .484 .546 .607 .668 .730];
F=[0.49 0.98 1.47 1.96 2.45 2.94 3.43 3.92 4.41 4.90 5.39 5.88];
plot(x,F,'b.')
hold on
coefs=polyfit(x,F,1);
x_vec=0:.001:.8;
F_vec=coefs(1)*x_vec+coefs(2);
plot(x_vec,F_vec,'r')
grid on
title('Force of Weight vs Spring Stretch')
xlabel('Spring Stretch (m)')
ylabel('Force of Weight (N)')
legend('Actual Data','Line of best fit','Location','Southeast')
text(.55, .875, 'F = 8.0696 * X + 0.0015')
hold off
fig=gcf;
fig.Position=[400 35 625 600];
ax=gca;
ax.XTick=[0:.05:.8];
ax.YTick=[0:.25:7];

답변 (1개)

Rahul
Rahul 2024년 9월 5일
편집: Rahul 2024년 9월 5일
I understand that you are trying get a full page graph as a 'pdf' file from the code shared by you. Your code currently only mentions the code for the 'plot' and adjusting the size and position of the 'figure'.
You can follow the following steps to achieve the desired result:
  • Adjust the 'figure' properties to achieve a full page graph using 'set' function.
% Adjust figure properties for full-page PDF
fig = gcf;
set(fig, 'PaperPositionMode', 'auto');
set(fig, 'PaperUnits', 'inches');
set(fig, 'PaperSize', [8.27, 11.69]); % A4 size
set(fig, 'PaperPosition', [0, 0, 8.27, 11.69]); % Full page
  • Using the 'print' function to save the figure as a 'pdf' file
% Save the figure as a PDF
print(fig, 'full_page_graph.pdf', '-dpdf', '-fillpage');
You can refer to the following documentations to know more about these functions:
Hope this helps! Thanks.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by