How do I improve the image quality of a plot in a published pdf or html?

조회 수: 25 (최근 30일)
Christopher Abel
Christopher Abel 2018년 12월 10일
편집: Nathan Jessurun 2018년 12월 10일
Whether I publish directly as a pdf or from html to pdf, the image quality of the plots is horrible. Can anyone help me out with this?

답변 (1개)

Nathan Jessurun
Nathan Jessurun 2018년 12월 10일
편집: Nathan Jessurun 2018년 12월 10일
Are you using the vector export option? This makes your graphs and other figures scale perfectly with different zooms. Try this:
fig = figure(1);
plot(1:10, 1:10);
print(fig, 'myFileName.pdf', '-dpdf','-r0')
Unfortunately, this saves the figure at the default figure size. You can change this, though. I made a method to do this -- you can change the scaling parameters as needed to produce a better output.
function saveFig(name, figNum)
fig = figure(figNum);
allAxs = findall(gcf, 'type', 'axes');
fig.Units = 'inches';
fig.PaperPositionMode = 'auto';
fig.Position = [1 1 16 4.5];
fig.PaperUnits = 'inches';
pos = fig.Position;
fig.PaperSize = [pos(3), pos(4)];
for ax = 1:length(allAxs)
% Trim whitespace around figures
outerpos = allAxs(ax).OuterPosition;
ti = allAxs(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);
allAxs(ax).Position = [left bottom ax_width ax_height];
end
print(fig, name, '-dpdf','-r0')
end
Basically you pass the file name and figure number to the function, and it stretches the x axis for signal plots and saves the file as a pdf vector graphic.

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by