Effacer les filtres
Effacer les filtres

Contourf lines showing up on PDF

19 vues (au cours des 30 derniers jours)
Austin
Austin le 7 Déc 2023
Commenté : Adam Danz le 12 Déc 2023
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:
PDF:
  6 commentaires
Star Strider
Star Strider le 7 Déc 2023
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
Dyuman Joshi le 8 Déc 2023
@Austin, Is saving the plot directly as pdf an option?
As that generates a high quality image.

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 8 Déc 2023
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 commentaires
Austin
Austin le 11 Déc 2023
I have been using edit and copy figure, then pasting it into my PowerPoint manually. I haven't been making a PDF originally because the PowerPoint is my main form of showing the data. I was only converting it to PDF to make the file size smaller for easier emailing when I noticed this issue.
The code I used to plot the black dots was as follows:
hold on
plot(A.X_Distance,A.Y_Distance,'.',"Color","black");
hold off
axis equal
This data comes from the table of my original data. The X, Y, and Z used in the contour plot were extrapolated using a meshgrid and then griddata function as follows:
m = 50; n = 50;
xi = linspace(min(A.X_Distance),max(A.X_Distance),m);
yi = linspace(min(A.Y_Distance),max(A.Y_Distance),n);
[X,Y] = meshgrid(xi,yi);
Z = griddata(A.X_Distance,A.Y_Distance,A.Z_Value,X,Y);
Adam Danz
Adam Danz le 12 Déc 2023
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by