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

25 次查看(过去 30 天)
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