How do I improve the image quality of a plot in a published pdf or html?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
Nathan Jessurun
le 10 Déc 2018
Modifié(e) : Nathan Jessurun
le 10 Déc 2018
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.
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!