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

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

采纳的回答

Sai Sri Pathuri
Sai Sri Pathuri 2020-7-15
编辑:Sai Sri Pathuri 2020-7-16
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 个评论
Mango Feng
Mango Feng 2020-7-19
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');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by