Adjusting plot fill to show two colours depending on overestimation/underestimation
古いコメントを表示
Hello,
I have the following code to plot my observed readings versus my modelled readings and the code works fine but does not clearly show regions where my modelled data is greater than observed data.
% Create figure
figure1 = figure;
XData = mod1_2001_2014(x,1)';
YData1 = mod1_2001_2014(x,5)';
YData2 = mod1_2001_2014(x,4)';
% Plot with fill
X = [XData fliplr(XData)];
Y = [YData1 fliplr(YData2)];
fill(X,Y,[0.678431391716003 0.921568632125854 1]);
ylim([0 max(YData2)+3])
I was wondering if there is a way to have this so that when the YData2 > YData1 the fill is red and when YData1 > YData2, the fill is the colour it is now.
Any ideas? Thank you!
採用された回答
その他の回答 (1 件)
Luuk van Oosten
2014 年 11 月 27 日
Dear Massao,
I do not know exactly how your data looks like, but you could use somthing like:
for i=1:lenght(yourdataset)
if YData1 < YData2 % Let matlab check if Ydata2 is larger than YData1
scatter( x(i,1), y(i,5), 15, [1 0 0], 'filled') hold on;
else % if this condition is not matched, then do the following:
scatter( x(i,1), y(i,4),15, [0 0.68 0.92], 'filled') hold on;
end
Have fun!
3 件のコメント
mashtine
2014 年 11 月 27 日
Luuk van Oosten
2014 年 11 月 27 日
Oops, excuse me. I'm not very familiar with plotting lines.
nevertheless, if you try something analogous to
if Ydata1 < Ydata2
fill stuff in fancy blue
else
fill stuff in red
I would expect that to work.
mashtine
2014 年 11 月 27 日
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!