1D Plot with custom colours
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Say I need to plot two vectors x and y using a standard line plot. What is the fastest way to color each point of the graph depending on the quadrant it's in (so that for example the portion of the graph inside the first quadrant is blue, the one in the second quadrant is red etc.)?
0 comentarios
Respuestas (1)
Walter Roberson
el 9 de Sept. de 2020
Editada: Walter Roberson
el 9 de Sept. de 2020
plot() as usual to get the vectors. Then scatter() markers on top of that, passing in the color information as the fourth parameter, scatter(x, y, size, color)
You cannot solve this with a single plot() call or a single scatter() call by themselves. plot() does not permit different colors for the same line, and scatter() cannot join points.
There is also a possibility using patch(). There is a File Exchange contribution for colored lines that is based upon patch()
0 comentarios
Ver también
Categorías
Más información sobre Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!