1D Plot with custom colours
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 9 Set 2020
Modificato: Walter Roberson
il 9 Set 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 Commenti
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!