フィルターのクリア

how to color the difference between two variables specifing the colors

1 回表示 (過去 30 日間)
Michela
Michela 2015 年 12 月 24 日
回答済み: Image Analyst 2015 年 12 月 24 日
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!

回答 (1 件)

Image Analyst
Image Analyst 2015 年 12 月 24 日
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.

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by