Borrar filtros
Borrar filtros

How to plot histogram using given data ?

11 visualizaciones (últimos 30 días)
Safia
Safia el 23 de Feb. de 2023
Comentada: Voss el 24 de Feb. de 2023
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 comentarios
Adam Danz
Adam Danz el 23 de Feb. de 2023
> 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 el 24 de Feb. de 2023
@Adam Danz hello!
this is what i get with excel ,how to plot this in matlab?

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 24 de Feb. de 2023
% 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 comentarios
Safia
Safia el 24 de Feb. de 2023
@Voss thank you very much.
It is possible to modify its form like this
Voss
Voss el 24 de Feb. de 2023
Look into the hatchfill2 function on the File Exchange in the link shared by VBBV.

Iniciar sesión para comentar.

Más respuestas (1)

VBBV
VBBV el 23 de Feb. de 2023
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 comentario
Safia
Safia el 24 de Feb. de 2023
@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

Iniciar sesión para comentar.

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by