Colorbar distortion when figure saved as PDF

41 次查看(过去 30 天)
AR
AR 2025-8-19,21:41
评论: AR 2025-8-22,20:51
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
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
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.
  1 个评论
AR
AR 2025-8-22,20:51
Hi Sam, thanks for your answer. Indeed, I'd already figured out that this doesn't happen when you export the figure in a nonvectorized format. Moreover, I found, by checking parula(3), parula(4), parula(8), parula(16), and so on, that the more colors there are in the colormap, the slope of the boundary between the colors decreases. Keep in mind that no colormap is truly continuous. The standard parula colormap, for example, has 256 colors. What I suspect happens is that when there are so many colors, you simply can't make out this problem and it just appears as a smooth gradient. I think it is just a known problem with the latest version of MATLAB and it remains to be resolved.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

标签

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by