Colorbar distortion when figure saved as PDF
42 views (last 30 days)
Show older comments
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 Comment
Paul
on 20 Aug 2025 at 11:26
Not that it helps, but looks similar to, if not exactly the same as, the issue discussed in this thread.
Answers (1)
S@m
on 22 Aug 2025 at 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.
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!