How to make 2 histograms in one plot, containing large data
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I am trying to create a comparison plot- histograms of the temperature (its 2 files with 360 positions each) for 2 different cities in one figure. I created two variables: braT and pariT. Everything works when I make a histogram for each of them separately. I tried hold on command but there is an error:
figure(1)
hold on;
hist(braT,"FaceColor",[0,0,1]);
hist(pariT,"FaceColor",[1,0,0]);
Error using hist (line 53)
Input arguments must be numeric.
I tried creating one hist(braT) and add data of pariT but it doesnt create other bars. I want to get 2 bars next to each other, in different colors, representing temperature for 2 cities. The files in attachement.
댓글 수: 0
답변 (2개)
TADA
2018년 11월 10일
You should use histogram instead of hist. See https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram.html;jsessionid=6a1923605c7a0a5035a37ffe3b1a
hist accepts only the data and number of bins and no name-value options, which is the source of your error. Not to mention that it's deprecated.
댓글 수: 1
TADA
2018년 11월 10일
One more thing, you should format your question using the code format for better readability
madhan ravi
2018년 11월 10일
편집: madhan ravi
2018년 11월 10일
see https://www.mathworks.com/matlabcentral/answers/102019-is-there-a-way-to-add-multiple-histograms-to-the-same-plot-similar-to-plotyy-in-matlab-7-13-r2011b and download histyy.m file attached
load bra.mat
load pari.mat
figure(1)
histyy(outB,100,outP,100) %100 represents number of bins
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!