HISTOGRAM 2 COLOURS - positive numbers red, negative numbers blue

3 次查看(过去 30 天)
Hello,
I have a histogram showing temperature warming (positive numbers) and cooling (negative). It is based on linear regression and the basic code for hte histpgram part is below.
I am wondering is it possible to do the positive bars (there are 1000s) in red and the neg (100s) in blue? Similar to the split in the picture below the code (obviously without the arrow etc.).
slopes = slope_TSA(:);
slopes(isnan(slopes)) = [];
figure;
histogram(slopes);
ylim([0 180000]);
xlim([-0.0001 0.0002]);
title('Distribution of combined ctl slopes - TSA');

采纳的回答

madhan ravi
madhan ravi 2018-12-4
编辑:madhan ravi 2018-12-4
EDITED
h=histogram(slopes(slopes>0));
h.FaceColor='red'
hold on
h1=histogram(slopes(slopes<0));
h1.FaceColor='blue'
  7 个评论
aine gormley
aine gormley 2018-12-4
Thanks, tho this function doesnt seem to display right - even using the example. I will open a new query regarding this, thanks for your time

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by