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

RE: st: Re: area between reference lines

From   "Steichen, Thomas J." <>
To   "''" <>
Subject   RE: st: Re: area between reference lines
Date   Tue, 11 Nov 2008 09:24:37 -0500



One possibility is to creat the "buffer" yourself. Here I place a 4% buffer on the y-axis using yscale(range()) and some pre-calculations (if desired, one could do something similar for the x-axis). My preference is for subtle shading (as shown) but many other preferences exist.


sysuse uslifeexp, clear
* range y variables and set buffer
qui summ le_male
local min = r(min)
local max = r(max)
qui sum le_female
local min = min(`min', r(min))
local max = max(`max', r(max))
local buff = (`max'-`min') * 0.04
local min = `min' - `buff'
local max = `max' + `buff'
* do plot
tempvar aux
g `aux'=`max'
tw (area `aux' year if year>=1915 & year<=1921, col(emidblue*.25)) ///
   (line le_female year) (line le_male year) ///
   (scatteri 80 1921 "WW-I & " 78 1921 "Spanish Flu" 80 1945 "Post WW-II", s(i)) ///
   , legend(order(2 3)) xli(1945, lcol(emidblue*.5)) plotr(m(zero)) yscale(range(`min' `max'))

Thomas J. Steichen

-----Original Message-----
From: [] On Behalf Of Michael Hanson
Sent: Monday, November 10, 2008 10:04 PM
Subject: Re: st: Re: area between reference lines

Thanks, Tom: -plotregion(margin(zero))- is a useful option to know --
I would not have found it without your suggestion.  However, in
testing it, I noticed that forcing the margins of all graphs to zero
(which it must do to preserve the y-axis range) can have undesirable
side effects.  For example, if you replicate Martin's earlier example
with this option, the line graph will touch the x-axis in 1918.
There are circumstances where this behavior would be fine, but others
in which it would not -- and I prefer the default behavior of Stata
to "buffer away" the lower limit of the line graph from the axis in
this case.

Thus, I still find my "hack" of using a large range of dates within a
-tline- command to be preferable.  I still would like to see
StataCorp modify -tline- to accept a date range rather than a list of
individual dates, as this option would make my "hack" a little
cleaner and easier to use.


On Nov 10, 2008, at 8:53 AM, Steichen, Thomas J. wrote:

> <<remailer munchie>>
>  Try adding option -plotr(m(zero))- to your plot. This will remove
> the gap.
> Tom
> -----------------------------------
> Thomas J. Steichen
> -----------------------------------

CONFIDENTIALITY  NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index