Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: histogram with freq and percent labels


From   Philipp <[email protected]>
To   [email protected]
Subject   st: histogram with freq and percent labels
Date   Mon, 24 Feb 2014 12:07:19 +0100

Hi everyone, 

I'd like to create an histogram with frequency values and additionally I'd like to add labels of the frequency and the percentage.
Without percentage label it is easy:
hist x, freq addlabes

My first idea was:
hist x, freq addlabels addplot(x, percent addlabels)
but addlabels is not working in the addplot-option.

My second idea was adding a third plot (plot3) in plotregion1 (you can see that there already exist two plots when you enter the Graph Editor. One is for the bars and the other for the frequency labels. I have honestly no idea how to add a third plot, but i tried something):

x can be 1, 2, 3:

sum x
local OBS r(N)
tab x, matcell(M)
		matrix list M
		display `OBS'
		local p1 = M[1,1]/`OBS'
		local p2 = M[2,1]/`OBS'
		local p2 = M[3,1]/`OBS'
display `p1' //is working		
	
local i1=1
forvalues i of local N1 N2 N3 {
gr_edit plotregion1.barlabels[`i1'].text = {}
gr_edit plotregion1.barlabels[`i1'].text.Arrpush N=`i'
local ++i1
}

Can anybody help me? Thanks in advance :)

Best, 
Philipp
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index