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

27 ビュー (過去 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 Center および File ExchangeVisual Exploration についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by