How do I create a 2-D or 3-D line that changes colors along the data points?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 20 de En. de 2010
Editada: MathWorks Support Team
el 3 de Dic. de 2020
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.
Respuesta aceptada
MathWorks Support Team
el 7 de Jul. de 2016
Editada: MathWorks Support Team
el 3 de Dic. de 2020
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!