How to create a horizontal histfit plot?
Afficher commentaires plus anciens
Dear mathworks community,
I would like to plot my data as a horizontal histogram with fitted gaussian. However, I have encountered a problem. I plotted my data using:
h = histfit(data)
Then, I wanted to change the orientation of the plot. I was able to do it for the histogram using:
h(1).Horizontal = 'on'
However, there seem not to be a 'Horizontal' option for the fitted gaussian. Indeed, when I run get(h(2)), I didn't see an 'Orientation' or a 'Horizontal' property. Of course, a histfit plot with horizontal histogram and vertical fitted gaussian is meaningless.
Is there a way to resolve this issue? I will be very grateful for your help. Kasia
Réponses (1)
Star Strider
le 16 Mai 2018
Try this:
h = histfit(data);
h(1).Horizontal = 'on';
Hy = h(2).XData;
Hx = h(2).YData;
h(2).Visible = 'off';
hold on
plot(Hx, Hy, 'LineWidth',2)
hold off
Catégories
En savoir plus sur Descriptive Statistics and Visualization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!