plot multiple histograms with different data in same range

66 ビュー (過去 30 日間)
Ali alshamrani
Ali alshamrani 2020 年 11 月 11 日
コメント済み: Ali alshamrani 2020 年 11 月 12 日
Hi all,
I am trying to plot a histogram which I have three different sets of data in the same range. However, I attatched both code and excel file of the data. I want to plot all three sets having 5 bins and width must be 4. Showing each set with different color.
Thanks,
  1 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 11 月 11 日
Sorry, but it's not clear to me yet what it is you want to achieve.
  • Are all 3 data sets combined or separate?
  • Are there 5 bins total or 5 for each data set (total of 15)?
  • What do you mean by the width must be 4?

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

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 11 月 11 日
Taking a stab at this anyway. You cannot group data in histograms. For that, you'll need to use a bar plot. Use histcounts to get the data you need to create the histograms using bar.
Here's a first approach. Note that readtable uses the column headers to create variable names. The warning is because some of these header names are not valid variable names. You can follow the suggestion(s) in the warning or ignore it.
annularrimx = readtable('all_droplets.xlsx');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
edges = 0:4:20;
[N,edges] = histcounts(annularrimx.sept_18V1_2,edges);
[N1,edges] = histcounts(annularrimx.oct_2V1,edges);
[N2,edges] = histcounts(annularrimx.sept_30V1,edges);
bar([N;N1;N2]')
xlabel('Diameter of droplet');
ylabel('number of droplet');
xticklabels(string(edges(1:end-1)) + "-" +string(edges(2:end)))
legend(annularrimx.Properties.VariableNames([8 6 4]),'Interpreter',"none")
  4 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 11 月 12 日
What do you mean? How are they interfering?
If you mean overlapping, they're not. See the definition of how edges work here.
Ali alshamrani
Ali alshamrani 2020 年 11 月 12 日
yes I meant the overlapping. As you can see here, I increased the bins width and they become like this(attached pic).

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by