Construct a Histogram plot using directional bins

조회 수: 13 (최근 30일)
Iulia Anton
Iulia Anton 2020년 4월 23일
댓글: Iulia Anton 2020년 4월 23일
I need to create a scatter table representing the proportional frequency of different sea states. For this I have 3 arrays (Hs_10yr, Te_10yr and Dir_10 yr). I nedd a scatter table with bins using the parameters Hs and Te but for different directional bins (windows). I already have the script for scatter table but I don't know how to set the condition for example to get a table for Dir = 180: 270 degree.How can I obtain this?
hFig = figure;
hAxes = axes(hFig);
xVals = Te_10yr;
yVals = Hs_10yr;
xEdges = 1:0.5:12.5;
yEdges = 0:0.5:4.5;
%yEdges = min(yVals):0.5:max(yVals);
hist_Counts = histcounts2(xVals,yVals,xEdges,yEdges);
hist_Counts_normalized = (hist_Counts / sum(hist_Counts,'all'))*100;
hHist = histogram2(hAxes,'XBinEdges',xEdges,'YBinEdges',yEdges,'DisplayStyle','tile','BinCounts',hist_Counts_normalized);
colormap(colorMap_occ);
colorbar;
xBinCenters = hHist.XBinEdges - [0,diff(hHist.XBinEdges)/2];
yBinCenters = hHist.YBinEdges - [0,diff(hHist.YBinEdges)/2];
for i = 2:numel(xBinCenters)
for j = 2:numel(yBinCenters)
x_loc = xBinCenters(i);
y_loc = yBinCenters(j);
if ~(round(hHist.Values(i-1,j-1),4) == 0)
text(hAxes,x_loc,y_loc,[num2str(round(hHist.Values(i-1,j-1),3),'%4.3f'),'%'],'Color',[0 0 0],'FontSize',9,'FontWeight','bold','HorizontalAlignment', 'center');
else
continue
end
end
end
box(hAxes,'on');
grid(hAxes,'on');
axis(hAxes,'tight');
hold(hAxes,'off');
  댓글 수: 2
Steven Lord
Steven Lord 2020년 4월 23일
What do you mean when you use the term "different directional bins (windows)"? Do you mean you want to have bins along x and y that are different widths? That's not going to be hard to do.
Do you have a picture of what you're hoping to receive as the end result? It kind of looks from your text calls like you want a heatmap but I'm not 100% sure.
Iulia Anton
Iulia Anton 2020년 4월 23일
Yes it is a heatmap. To be more exactly I want to filter data that apears in heatmap (Hs and Te) depending the Dir variable. I don't need Dir to appear in my heatmap. It is used only to filter data (Hs and Te). So the variable Dir is between 0 and 360 and I need to get data of Hs and Te only for Dir between 90 and 180.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by