# How exactly is the first vertex of a patch in surf determined?

4 views (last 30 days)
Tim M.J. Nijssen on 23 Sep 2020
Commented: Tim M.J. Nijssen on 23 Sep 2020
In the documentation for the surf command it is stated that for faceColor = 'flat', "The color value at the first vertex of each face (in the positive x and y directions) determines the color for the entire face."
Paired with the accomanying drawing, I completely understand how this work for a rectangular grid. However, I would like to know what exactly is the 'first vertex' in case of a non-rectangular grid. I'm trying to make a polar plot with surf, and this is vital information.
PS, I tried to find out through the source of surf, but it seems like the magic happens in a .p file.
Thank you

Show 1 older comment
Tim M.J. Nijssen on 23 Sep 2020
A grid yes, a monotonic, rectangular grid, not necessarily, as you can see below.
r = 0:0.1:1;
phi = 0:pi/10:2*pi;
x = cos(phi).*r';
y = sin(phi).*r';
z = rand(size(x));
surf(x,y,z)
view(2)
axis equal Steven Lord on 23 Sep 2020
As far as I'm aware it's not possible to create a surf plot on a polaraxes.
>> ax = polaraxes;
>> [x, y, z] = peaks;
>> surf(ax, x, y, z)
Error using matlab.graphics.chart.primitive.Surface
Surface cannot be a child of PolarAxes.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Trying to create a surf plot on an axes containing an older style polar plot probably won't do what you expect or want.
>> th = 0:0.1:2*pi;
>> r = 1:length(th);
>> h = polar(th, r);
>> ax = ancestor(h, 'axes');
>> hold on
>> surf(ax, x, y, z)
So can you explain a bit about how you are "trying to make a polar plot with surf"?
Tim M.J. Nijssen on 23 Sep 2020
please refer to my comment above, I created a polar representation inside a cartesian axes

R2018a

### Community Treasure Hunt

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

Start Hunting!