Colorbar distortion when figure saved as PDF
조회 수: 22 (최근 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일
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일
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!