Clear Filters
Clear Filters

Removing lines in scatter plot when using shading interp

6 views (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 12 Jul 2012
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.

Sign in to comment.

Answers (2)

Kelly Kearney
Kelly Kearney on 12 Jul 2012
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 on 12 Jul 2012
Thanks! that worked!

Categories

Find more on Contour 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!