how to plot each bin of data individually?

5 ビュー (過去 30 日間)
MA
MA 2021 年 10 月 17 日
コメント済み: MA 2021 年 10 月 19 日
I am having the follwoing issues:
I have a table with three variables: time in hours, altitude and solar activity, according to a time interval of 3hrs I have divided my data into 8 bins using the function discretize.
How can we plot the data within each bin indiviually, i.e we have 8 bins we would like to have a graph for each bin, that is for each interval of time, so at the end we get 8 graphs.
in the plot the data of each row sholud be presented for ex by a dot.
attached is a text file containing a sample of the data I am working with.

採用された回答

dpb
dpb 2021 年 10 月 17 日
As per usual, would be easier to demonstrate with some real data to work with...but
tD=table(repmat([0:23].',4,1),randi([150 200]*1000,96,1),randi([10 70],96,1),'VariableNames',{'Hours','Altitude','Activity'});
tD.Bin=discretize(tD.Hours,8);
splitapply(@(x,y) plot(x,y,'*'),tD.Altitude,tD.Activity,tD.Bin)
xlabel('Altitude, ft')
ylabel('Activity, units')
tCenter=[1.5:3:24]; % bin time centers 0-3, 3-6, 6-9, ...
legend(compose('Time Bin %4.1f hrs',tCenter.')) % label by the group time centers
might be a fair starting point...
  3 件のコメント
dpb
dpb 2021 年 10 月 18 日
I'm sure there is, but what, specifically, do you mean? The above is for each bin.
MA
MA 2021 年 10 月 18 日
編集済み: MA 2021 年 10 月 18 日
What I mean is that the plot here will display all the bins together in one plot. But what if we are interested in visualizing only the data within a certain bin. since the bins we have represents intervals of time, we would like the plot to plot only one specified bin i.e specified interval of time. would that be possible?

サインインしてコメントする。

その他の回答 (2 件)

dpb
dpb 2021 年 10 月 18 日
OK, here's another example; I'll add it as its own Answer -- carrying on from the above
uBin=unique(tD.Bin);
for i=uBin(:).'
nexttile
isBin=(tD.Bin==i);
scatter(tD.NE8(isBin),tD.GDALT(isBin),'.')
legend("Bin "+i,'Location','best')
xlabel('NE, units'),ylabel('GDALT, ft')
box on
end
  1 件のコメント
MA
MA 2021 年 10 月 19 日
That is exactly what I am after, I really appreciate all the help you provided, thank you so, so much.

サインインしてコメントする。


Steven Lord
Steven Lord 2021 年 10 月 18 日
Can you tell us which of the thumbnail pictures for the plotting functions included in MATLAB look closest to what you want to plot? If none of them do and you have other MathWorks toolboxes installed, open the Plots tab on the Toolstrip and see if any of the functions from a toolbox have thumbnails that look closer (maybe a boxplot from Statistics and Machine Learning Toolbox?)
  6 件のコメント
dpb
dpb 2021 年 10 月 18 日
It's easy to overthink a problem, indeed... :)
Glad to help.
Investigate rowfun and friends if you do other analyses on these data by the grouping variable(s) -- extremely powerful construct for such purposes.
MA
MA 2021 年 10 月 19 日
Thank you for the advice, I will definitely check them out.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by