Is it possible to extract bars from the hist or histogram function?
Mostrar comentarios más antiguos
I would like to extract the bar-rectangle coordinates (the shapes themself) from the histogram plot. Is it possible?
8 comentarios
Steven Lord
el 28 de Sept. de 2015
Why?
Mr M.
el 28 de Sept. de 2015
Walter Roberson
el 28 de Sept. de 2015
Is it possible that using a hgtransform() would work for your purpose? If you have a graphics object that does not allow you to directly position it in an axes, you can parent the graphics object to an hgtransform and use that to scale and translate it.
Steven Lord
el 29 de Sept. de 2015
Can you show a picture of the type of "graphic matrix" you want? I'm not quite sure I understand what you're trying to do quite yet.
Mr M.
el 29 de Sept. de 2015
Walter Roberson
el 29 de Sept. de 2015
Mr M.
el 30 de Sept. de 2015
Editada: Walter Roberson
el 30 de Sept. de 2015
Walter Roberson
el 30 de Sept. de 2015
data = [rand(1,50)];
xlim([0 2]);
ylim([0 100]);
h1 = hgtransform('Matrix',makehgtform('scale',0.5));
[n,x] = hist(data);
bar(x, n, 'Parent', h1);
drawnow;
The difficulty that you ran into is that when you specify output variables, hist() does not draw the histogram, and instead just returns the computed data. The newer histogram() function always draws the data and returns the handle.
Respuestas (2)
Walter Roberson
el 28 de Sept. de 2015
2 votos
If you are using hist() to do the plot, then it uses bar() to do the plots, and bar() creates a patch() object; see http://www.mathworks.com/help/matlab/ref/hist.html#btsgtr1-1_1 . You can examine the properties of the patch() object. It will not be the most fun you've had all day, but it can be done (I have done it.)
Thorsten
el 28 de Sept. de 2015
The values you are looking for are returned by the histogram function:
h = hist(x);
plot(h)
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!