How do I create a 2-D or 3-D line that changes colors along the data points?
3 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2010 年 1 月 20 日
編集済み: MathWorks Support Team
2020 年 12 月 3 日
I would like to plot a 2-D or 3-D line plot so that the colors change as the amplitude along the axes increases.
I would like to know how to produce a 3-D plot that uses the colormap for shading.
採用された回答
MathWorks Support Team
2016 年 7 月 7 日
編集済み: MathWorks Support Team
2020 年 12 月 3 日
The MATLAB function, "plot3c.m", mimics the MESH command in a creative way to make a 2-D or 3-D line plot. Similar to how the mesh plot uses the colormap for shading, the color of the line will change with respect to the value of the specified axis in the "plot3c.m".
You can find the file at the following location:
Here is an example that uses this function to create a 2-D line of discrete markers that changes color with it's amplitude:
t = linspace(0,5*pi,100);
y=sin(t);
plot3c(t,y,0*t,y);
view(2)
colorbar
Here is an example that creates a scatter plot:\n
t = linspace(0,2*pi,40);
x = sin(t);
y = cos(t);
z = t.*x.^2;
plot3c(x,y,z,t,'x');
Alternatively, you may be interested in the SCATTER or SCATTER3 command. These can create scatter plots with point of varying colors. See the documentation for more information on these commands.
In addition the following file at the Matlab file exchange:\n
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9519&objectType=file
also provides an alternative efficient plotting routine that calls the PLOT3 routine only once for each group of points that map to the same color.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!