Wrong pixel color when save figure as pdf using a different background color

4 vues (au cours des 30 derniers jours)
When I function imshow to display an image and change the default color, everything is okay. However, when I save the figure to pdf format, the color of white pixel is not correct.
set(groot, 'DefaultFigureColor', 'blue');
set(groot, 'DefaultFigureInvertHardcopy', 'off');
p = phantom();
figure(1)
imshow(p)
saveas(gcf, 'phantom.pdf');
This is the result of Figure 1.
This is the result in file 'phantom.pdf'.
  1 commentaire
N/A
N/A le 9 Juil 2020
I don't know if this helps you, but try export_fig . it served me well so far when I wanted to export things to pdf.

Connectez-vous pour commenter.

Réponse acceptée

Sai Sri Pathuri
Sai Sri Pathuri le 15 Juil 2020
Modifié(e) : Sai Sri Pathuri le 16 Juil 2020
The cause is that renderer we use to print is switched to painters. You may use -opengl flag with print command
print(gcf, 'phantom', '-dpdf', '-opengl')
  1 commentaire
Mango Feng
Mango Feng le 19 Juil 2020
Thanks for your answer! I found that an alternative method is changing the figure property 'Renderer' to 'opengl'.
set(groot, 'DefaultFigureColor', 'blue');
set(groot, 'DefaultFigureInvertHardcopy', 'off');
p = phantom();
figure('Renderer', 'opengl')
imshow(p)
saveas(gcf, 'phantom.pdf');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by