Graphs (x, y, z) of triplets over the coordinates (x, y) with color z

I have a list of points (x, y, z) and you want to visualize them as a curve on a plane with points on (x, y) and any color / intensity / thickness like z. How can this be done in Matlab?

plot(x,y)gets the right shape, but I need the color to depend on z.

+4
source share
2 answers

Assuming you're not interested in the color of the actual string, but markers. Use plotin conjunction with scatter.

Provide the following sample data:

t = 0:pi/20:2*pi;
x = sin(t);
y = cos(t);
z = t;

plot3(x,y,z);

enter image description here

Built in a 2D plane:

plot(x,y); hold on
scatter(x,y,300,z); hold off

leads to:

enter image description here

: , , scatter, , .


, MATLAB Central, , .

surface([x;x],[y;y],zeros(2,length(t)),[z;z],'EdgeColor','flat',...
        'Marker','o','MarkerSize',10,'MarkerFaceColor','flat');

enter image description here


, z, , scatter:

surface([x;x],[y;y],zeros(2,length(t)),[z;z],'EdgeColor','flat'); hold on
MarkerSize = round(z*1000)+1;
scatter(x,y,MarkerSize,z,'.','MarkerFaceColor','auto'); hold off

enter image description here

z . patch.

+3

,

x = 0:.05:2*pi;
y = cos(x);
planez = zeros(size(x));
z = x;  % This is the color, vary with x in this case, but you can use your vector
surface([x;x],[y;y],[planez;planez],[z;z],...
        'facecol','no',...
        'edgecol','interp',...
        'linew',2);

, , . , plot

enter image description here

+1

Source: https://habr.com/ru/post/1526018/


All Articles