Contourf lines showing up on PDF
37 次查看(过去 30 天)
显示 更早的评论
I created some contourf plots, set the LevelStep to 1, and removed the lines using LineStyle='none'. I can copy and paste the figure into PowerPoint and they look great, exactly like I want. But then, when I save the PowerPoint file as a PDF, white lines will appear that look like the contour lines. Is there any way to get it so that they will not show up in the PDF. Attached is the code as well as screenshots from the PPT and the PDF (The black dots are just a scatterplot that I overlaid on the contour plots). Thanks in advance!
[M, c] = contourf(X,Y,Z,'LineStyle','none');
colormap turbo
clim(limits);
c.LevelStep = 1;
xticklabels("");
yticklabels("");
PPT:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563164/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563164/image.png)
PDF:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563169/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563169/image.png)
6 个评论
Star Strider
2023-12-7
If you want the colours only and not the lines, another option might be to use surf instead, with 'FaceColor','interp', 'EdgeColor','interp' and ‘view(0,90)’.
Dyuman Joshi
2023-12-8
@Austin, Is saving the plot directly as pdf an option?
As that generates a high quality image.
采纳的回答
Adam Danz
2023-12-8
I tested this in R2023a (and 23b) with the following workflow and could not reproduce the result reported in the question.
[X Y Z] = peaks();
[M, c] = contourf(X,Y,Z,'LineStyle','none');
colormap turbo
% clim(limits);
c.LevelStep = 1;
xticklabels("");
yticklabels("");
copygraphics(gcf,'ContentType','image','BackgroundColor','none')
% Paste in ppt
% Save as pdf
% open pdf file
I noticed the reproduction steps in the quesiton aren't complete since they do not produce the black dots. Be sure you're not plotting anything else to those axes such as a second controup map.
I'm curious how you are copying the figure to the powerpoint. If you haven't tried it already, try using copygraphics as shown in my answer or export the figure directly to a pdf format using
exportgraphics(gcf, 'myFig.pdf','ContentType','vector')
2 个评论
Adam Danz
2023-12-12
The issue is likely caused by the conversion from ppt to pdf. The copied figure is a vector image unless you've changed the default copy behavior. When the ppt file is saved as a PDF, my guess is that the image is flattened which results in the lines mysteriously appearing. I doubt it has anything to do with MATLAB, although I could be wrong. Another possibility is the color borders creating an edge during the flattening process. I briefly looked for potential causes of lines appearing at color borders when saving a ppt ot pdf. There were lots of issues reported with this conversion but I didn't find any close matches to this specific problem.
When copying the figure from MATLAB to ppt, if you copy the figure as png rather than in vector format, my bet is the problem goes away because then it's already in vector format in the PPT.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!