[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hist plot
Re: Hist plot
Thu, 11 Dec 2008 15:10:28 +0100
On Wed, Dec 10, 2008 at 10:39 PM, Oscar Bayona Candel
> Hi all,
> An easy question.
> I have a row vector A=[0.02 0.04 0.04 0.01];
> I want to plot this vector trough "hist" plot function. I want to show on
> top of each bar the value but in percentage. It is possible to make it?
> Thanks in advance¡¡¡
don't you rather mean using 'bar' function to make a bar plot? That
would make more sense for vector with just 4 elements... Anyway,
adding text labels on top of bars is possible, but AFAIK you have to
do it manually with 'text' function. If bar x positions go from 1 to
length(A) (which is the default case), it is relatively simple:
A=[0.02 0.04 0.04 0.01];
text(i, A(i)+0.001, sprintf('%.2f%%',100*A(i)),
This inserts text labels with x,y coordinates i,A(i)+0.001 (0.001 is
added so that text is above the bars - you may have to find right
number individually for other plots).
If you wanted to do this with histogram, you would need to find out
x,y coordinates from 'hist' return values:
[NN XX] = hist(A)
will return y coordinates (number of observations in specific bin) in
NN and x coordinates (centers of bins) in XX.
- Hist plot, Oscar Bayona Candel, 2008/12/10
- Re: Hist plot,
Ivan Sutoris <=