how to color the difference between two variables specifing the colors
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I am a beginner user of this very useful (but, for me, weird :-) ) software. As far, I have not so many problems, but now I need to create a figure in which I have two lines (one for each column of my matrix pM) and the area inside these lines has to be colored in red if the difference between the value of the two columns is negative, in blue otherwise. In other words, i=pM(:,1)-pM(:,2) if i<0 the area between pM(:,1) and pM(:,2) is red. How can I implement it in matlab???? Thank you!
0 Commenti
Risposte (1)
Image Analyst
il 24 Dic 2015
Here's a start:
pM = rand(20, 2)
col1 = pM(:, 1);
col2 = pM(:, 2);
area(col1, 'FaceColor', 'b');
hold on;
area(col2, 'FaceColor', 'r');
legend('col1', 'col2');
minY = min([col1,col2], [], 2)
area(minY, 'FaceColor', 'w');
plot(col1, 'bo-', 'LineWidth', 2);
plot(col2, 'rd-', 'LineWidth', 2);
grid on;
If you want it to follow the slants, then you're going to have to increase the sampling so that you have data there.
0 Commenti
Vedere anche
Categorie
Scopri di più su Environment and Settings 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!