Removing lines in scatter plot when using shading interp

5 次查看(过去 30 天)
I'm using scatter and pcolor in the same axis but on different data. When I run shading interp on the pcolor plot, colored lines are plotted connecting all the scatter points on the other data. Here is an example:
[X,Y,Z] = peaks(30);
scatter(X(:),Y(:),20,Z(:),'filled')
shading interp
Does anyone know a way to get rid of those lines? while still preserving the way pcolor looks in the same axis?
Thanks
Ashley
  1 个评论
Walter Roberson
Walter Roberson 2012-7-12
Sorry, I do not see the pcolor()? pcolor() is a routine to create pseudo-color plots; you do not appear to have invoked it. pcolor() is not at all the same as shading interp.

请先登录,再进行评论。

回答(2 个)

Kelly Kearney
Kelly Kearney 2012-7-12
The shading command affects all surface and patch objects, including the child patch object that's part of a scattergroup object. You can manually set the edge color of that patch back to it's default value:
[X,Y,Z] = peaks(30);
pcolor(X,Y,Z+10);
hold on
hs = scatter(X(:),Y(:),20,Z(:),'filled');
shading interp;
set(get(hs,'children'), 'edgecolor', 'none')

Ashley
Ashley 2012-7-12
Thanks! that worked!

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by