Colorbar distortion when figure saved as PDF
41 次查看(过去 30 天)
显示 更早的评论
When I create a colorbar by calling colorbar, the colorbar lines are diagonal for some reason. In the figure, and a saved PNG image, it appears correctly (first image). But when I save the figure as a PDF file, the colorbar is distorted (second image).
The problem is there when I just call "colorbar" and change no settings. I tried changing the figure and colorbar positions so that the dimensions are multiples of 8 and also tried changing the figure resolution from 1000 to 2000, but I really have no idea what's causing the problem. It may just be my system (Mac OS) but someone else may have more insight.


1 个评论
Paul
2025-8-20,11:26
Not that it helps, but looks similar to, if not exactly the same as, the issue discussed in this thread.
回答(1 个)
S@m
2025-8-22,8:59
Hi,
I understand that the colorbar lines are being distorted when you are saving the MATLAB figure as a pdf file in R2025a on Mac OS. I am observing the same on Windows as well. I think the issue is not OS specific. I also observed that this issue only happens with discrete colormaps. There is no distortion with continuous colormaps like "parula”.
To work around this, I exported the figure to ‘pdf’ using the below command:
exportgraphics(gcf, 'myfigure.pdf', 'ContentType', 'image', 'Resolution', 600);
This resolved the issue for me. However, if I set 'ContentType' to 'vector' as shown below, the distortion still occurs.
exportgraphics(gcf, 'myfigure.pdf', 'ContentType', 'vector');
I hope this helps! For further assistance with the issue, you may reach out to MATLAB Technical Support using the link below.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!