How to remove lines when saving fill plot
3 views (last 30 days)
Show older comments
I am trying to plot a polygon with the coloring shaded with respect to a separate function. See code below taken from ``Area plot with gradient"--Patrick Kalita's answer on 16 Feb 2011:
% Define x, f(x), and M(x)
x = linspace(0, 2*pi, 20)';
f = cos(x) + 2;
M = x.^2;
% Define the vertices: the points at (x, f(x)) and (x, 0)
N = length(x);
verts = [x(:), f(:); x(:) zeros(N,1)];
% Define the faces to connect each adjacent f(x) and the corresponding points at y = 0.
q = (1:N-1)';
faces = [q, q+1, q+N+1, q+N];
p = patch('Faces', faces, 'Vertices', verts, 'FaceVertexCData', [M(:); M(:)], 'FaceColor', 'interp', 'EdgeColor', 'none')
If I save or print the image:
print -dpdf -r600 test1.pdf
I get lines going through the plot. See the figure here
Does anyone have a fix for this, or a reason why it happens? I've tried setting the patch so that there is only one face. The problem seems to be set in the 'interp' FaceColor. I've also tried setting the children edge color to none:
set(get(p,'children'), 'edgecolor', 'none')
however, this doesn't help.
Thank you,
Kevin
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!