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: placing two textboxes in a graph on the x-axis
From
Eric Booth <[email protected]>
To
"<[email protected]>" <[email protected]>
Subject
Re: st: placing two textboxes in a graph on the x-axis
Date
Sat, 27 Aug 2011 20:47:18 +0000
<>
Maarten already gave a solution, but here's a solution using the textbox() graph option you asked about in your original post (piggybacking on Maarten's code).
The tricky part about textbox is tweaking the x-y coordinate placement of the boxes. You can still place them below the axis using negative coordinates. I find that it's easier to stylize textboxes the way I want with shading, text direction, borders, etc, but sometimes it's a pain to get them in just the right spot (especially when your scaling changes -- manually setting the axis helps alleviate this issue).
*-------------- begin example ------------------
sysuse nlsw88, clear
replace grade = grade - 12
scatter ttl_exp grade , ///
text(-2.1 -2.8 "{bf:Favors Treatment}" "more text here", ///
orient(horizontal) si(small) justification(center) box ) ///
text(-2.1 2.8 "{bf:Favors Control}" "more text here", ///
orient(horizontal) si(small) justification(center) box ) ///
xtit("Grade Completed", size(small) margin(medlarge))
*---------------- end example --------------------
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
+979.845.6754
On Aug 27, 2011, at 9:36 AM, Ariel Linden, DrPH wrote:
> Maarten, you are fantastic! This is exactly what I needed! I didn't even
> know about xmlabel.
>
> Thanks for your help!
>
> Ariel
>
> Date: Fri, 26 Aug 2011 10:02:38 +0200
> From: Maarten Buis <[email protected]>
> Subject: Re: st: placing two textboxes in a graph on the x-axis
>
> On Thu, Aug 25, 2011 at 11:34 PM, Ariel Linden, DrPH wrote:
>> I would like to place 2 textboxes on the x-axis of a graph (one to the
> right
>> and one to left of the center point 0 where the xlabel would go) that says
>> "benefits treatment" and "benefits controls" (as you'd see in a forest
>> plot).
>
> What about this?
>
> *-------------- begin example ------------------
> sysuse nlsw88, clear
> replace grade = grade - 12
>
> scatter ttl_exp grade , ///
> xmlab(-2.5 `""benefits" "treatment""' ///
> 2.5 `""benefits" "controls""', ///
> noticks labsize(medium) )
> *---------------- end example --------------------
> (For more on examples I sent to the Statalist see:
> http://www.maartenbuis.nl/example_faq )
>
> Hope this helps,
> Maarten
>
> *
> * 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/