Print .eps or .pdf contourf plot with 'edgecolor','none' leaves white lines between levels - need to get rid of them (2019b)

9 次查看(过去 30 天)
Hi, I am having the following problem:
When I create a contourf plot and remove the lines between levels, as I try to print as .eps or .pdf, I end up with many unwanted white lines separating the levels. This does not happen when I print a .png or the number of levels is small.
I have reproduced the problem with the example for contourf given in Matlab website (https://www.mathworks.com/help/matlab/ref/contour.html), see code below.
The choice of colormap does not affect the result. However, I need to use colormap('grey'), and in that case the problem is even more obvious.
Thank you
clc, close all, clear all
Z = peaks;
colormap(gray);
contourf(Z,linspace(min(min(Z)),max(max(Z)),30),'edgecolor','none')
print('test','-dpdf');
print('test','-depsc2');
print('test','-dpng');
disp('DONE')

采纳的回答

Kiran Felix Robert
Kiran Felix Robert 2020-10-8
Hi Pablo,
The rendered white lines in a PDF file can be removed by force setting the renderer of the figure to opengl and using the saveas function instead of the print function.
The following is an example,
clc, close all, clear all
Z = peaks;
colormap(gray);
contourf(Z,linspace(min(min(Z)),max(max(Z)),30),'LineColor','none')
% To save the figure
set(gcf,'renderer','opengl');
saveas(gcf, 'test', 'pdf')
saveas(gcf,'test','epsc')
saveas(gcf,'test.png')
%%%%%
disp('DONE')
Kiran Felix Robert

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by