HISTOGRAM 2 COLOURS - positive numbers red, negative numbers blue

조회 수: 4 (최근 30일)
aine gormley
aine gormley 2018년 12월 4일
댓글: aine gormley 2018년 12월 4일
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에서 Spline Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by