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]

Re: st: RE: percent symbols in catplot


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: RE: percent symbols in catplot
Date   Sun, 28 Feb 2010 12:48:30 -0600

>
On Feb 28, 2010, at 11:39 AM, Nick Cox wrote:
> I have previously resisted the idea of being able to add "%" signs
> everywhere. Isn't a specification of percent on the graph margins
> sufficient? However, I'd add such an option to -tabplot- if it were
> clear that there were people who really wanted it. 


Nick, thanks for the example using -tabplot-.
One of the clients for which I do some consulting requires that the graphs be presented in this format to match graphs from other contributors & past versions of the graphs.  Similarly, they require % signs in all summary tables (for which -tabout- is quite useful).

I doubt that there is a widespread need for the % signs for bar labels in graphs like -tabplot-, and in most cases, I go with % signs in the margins (or I just use the axis label to convey this idea).  In this case, both of the "kludged" methods offered by you and Martin work perfectly.  


~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754



On Feb 28, 2010, at 11:39 AM, Nick Cox wrote:

> Eric started a thread under this heading which featured various
> exchanges with Martin Weiss. 
> 
> Replying to the original question: I am the author of -catplot-. The
> main issue is that -catplot- is purely a wrapper for -graph bar-, or
> -graph hbar- or -graph dot-, one of which is called depending on
> whatever is specified. 
> 
> In Eric's example -graph bar- is invoked. I confirm that I don't know a
> way to do this with high-level commands, as -graph bar- doesn't offer
> any such handle.
> 
> A similar graph is possible with -tabplot- from SSC, at present with a
> kludge 
> 
> sysuse auto, clear
> contract rep78, perc(_perc) nomiss
> gen toshow = string(_perc, "%3.2f") + "%"
> tabplot rep78 [aw=_perc] , showval(toshow)
> 
> That kind of thing is much easier as -tabplot- is based on -twoway-. 
> 
> I have previously resisted the idea of being able to add "%" signs
> everywhere. Isn't a specification of percent on the graph margins
> sufficient? However, I'd add such an option to -tabplot- if it were
> clear that there were people who really wanted it. 
> 
> Nick 
> [email protected] 
> 
> Eric Booth
> 
> I am using -catplot- (from SSC) on Stata 11 MP for Mac OSX.  I'd like to
> show the percent sign in the label for each of the category bars when
> using the "percent" option.
> 
> For example, 
> ****
> webuse auto, clear
> catplot bar rep78,  percent blabel(bar, position(outside) format(%9.1f))
> 
> **or**
> catplot bar rep78,  by( for)  percent blabel(bar, position(outside)
> format(%9.1f))
> ****
> shows the percent of each rep78 category out of 100, but I can't get it
> to show the % sign, so it could say "43.5%", etc.
> 
> Using graph editor, I found that I can add a % sign to the bar label
> text manually (though I'd rather not have to do that for many graphs),
> but after looking through the barlabel options help documentation, I
> couldn't figure out how to change the bar label automatically.  (I had
> the idea that if I could override the bar labels like you can the text
> for a key in a legend then I could calculate and substitute these values
> into the -catplot- command in a loop, but I haven't found a way to do
> this using the barlabel option)
> 
> Another option might be to write something that automates those graph
> recorder grec file changes (ex:  when I add the "%" by hand, it issues
> the command:
> 
> .plotregion1.barlabels[3].text.Arrpush 43.5%
> 
> in the recording), but this is a pain.  Any suggestions?
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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