How to plot histogram using given data ?

14 次查看(过去 30 天)
Hello!
I'm asking if it is possible to insert data in matlab and use them to plot histogram with different colors?
i have already used excel but i need a different form of histogram (bar forms), for example the first bar contains circles, the second contains squares,...
here is my data
Value first Second third
10 0,67 0,66 0,70
20 0,38 0,37 0,42
30 0,26 0,25 0,30
40 0,19 0,19 0,24
50 0,15 0,15 0,21
i need to see "first", "second" and "third" as function of value
Thanks in advance
  2 个评论
Adam Danz
Adam Danz 2023-2-23
> is it possible to insert data in matlab and use them to plot histogram with different colors?
Yes, one set of bars will be generated for each column of data, each with a different color.
data = randn(1000,3)+[-2 2 5];
hold on
histogram(data(:,1))
histogram(data(:,2))
histogram(data(:,3))
> i need a different form of histogram (bar forms)... the first bar contains circles, the second contains squares
Not sure what this means, please elaborate or show us an image.
Safia
Safia 2023-2-24
@Adam Danz hello!
this is what i get with excel ,how to plot this in matlab?

请先登录,再进行评论。

采纳的回答

Voss
Voss 2023-2-24
% Value first Second third
M = [ ...
10 0.67 0.66 0.70; ...
20 0.38 0.37 0.42; ...
30 0.26 0.25 0.30; ...
40 0.19 0.19 0.24; ...
50 0.15 0.15 0.21; ...
];
bar(M(:,1),M(:,2:end))
  2 个评论
Safia
Safia 2023-2-24
@Voss thank you very much.
It is possible to modify its form like this
Voss
Voss 2023-2-24
Look into the hatchfill2 function on the File Exchange in the link shared by VBBV.

请先登录,再进行评论。

更多回答(1 个)

VBBV
VBBV 2023-2-23
Check the answer from the below link
May be its hatch property of the bar which should be used. It seems this is not default Matlab property for bar & histogram functions. You need to use the below custom function available from File Exchange.
  1 个评论
Safia
Safia 2023-2-24
@VBBV thank you .This is what i need but at first i don't know how to plot hisotgram in matlab when i already have data

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by