3D scatter plot with 4D data

后端 未结 2 1133
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 05:32

I need to plot a 3D figure with each data point colored with the value of a 4th variable using a colormap. Lets say I have 4 variables X,Y,Z and W where W = f(X,Y,Z). I want

相关标签:
2条回答
  • 2020-12-07 05:56

    So just use z for the size vector (4th input) as well as the color vector (5th input):

    z = 10*(1:pi/50:10*pi);
    y = z.*sin(z/10);
    x = z.*cos(z/10);
    
    figure(1)
    scatter3(x,y,z,z,z)
    
    view(45,10)
    colorbar
    

    The size vector needs to be greater 0, so you may need to adjust your z accordingly.

    enter image description here

    0 讨论(0)
  • 2020-12-07 05:57

    You are already nearly there... simply use

    scatter3(X,Y,Z,s,W);
    

    where s is the point size (scalar, e.g. 3) and W is a vector with your W values. You might also want to issue an

    set(gcf, 'Renderer','OpenGL');
    

    where gcf gets your current figure you are plotting in to significantly increase responsiveness when scattering a lot of data.

    0 讨论(0)
提交回复
热议问题