2D Colored Plot
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I've created a script which runs for 100 different values of x and produces 3 different values of Y for each X.
Currently I have these lineplotted, but I think that's kinda boring and I would like to present the data differently.
Below is the current plot
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/693999/image.png)
I'd like it so that for every X value where one of the lines has a greater value than the other 2 it is colored in a certain color. Kinda like a contour or surface plot, but without a value for Z. I was thinking some sort of contour or heat map, but neither of those sound like they fit what I need. What plot would you suggest, if any, to do this.
For example. Between X values 1 to 14, the entire plot would be red, between 14 and 29 it'd be blue, and past 29 it'd be yellow.
I'd prefer if you pointed me in the right direction instead of just giving me code for this question, I really wanna learn how to do this because it's not something they taught in my coding course.
0 comentarios
Respuestas (1)
KSSV
el 24 de Jul. de 2021
You can get the indices of the required values and plot them with different colors.
x = 0:.05:2*pi;
y = sin(x);
figure
hold on
plot(x(y>=0),y(y>=0),'r')
plot(x(y<0),y(y<0),'b')
Or you may consider using this: https://in.mathworks.com/matlabcentral/answers/5042-how-do-i-vary-color-along-a-2d-line
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots 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!