Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Graph axis labelling range


From   "Steichen, Thomas J." <SteichT@rjrt.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Graph axis labelling range
Date   Mon, 19 Feb 2007 16:13:30 -0500

Don't have Tufte any more...

Is this near what you want?

sysuse auto
qui summ mpg
local ymn = r(min)
local ymx = r(max)
local yr = .05*(`ymx'-`ymn')
qui summ price
local xmn = r(min)
local xmx = r(max)
local xr = .05*(`xmx'-`xmn')
graph twoway scatter mpg price || ///
scatteri `ymn' `=`xmn'-`xr'' `ymx' `=`xmn'-`xr'', ///
  c(l) clcol(black) msym(none) || ///
scatteri `=`ymn'-`yr'' `xmn' `=`ymn'-`yr'' `xmx', ///
  c(l) clcol(black) msym(none)    ///
, plotregion(margin(l 0  b 0) lcol(none))legend(off) ///
  ylab(`ymn' `ymx', nogrid) yscale(ra(`ymn' `ymx')) yscale(noline) ///
  xlab(`xmn' `xmx', nogrid) xscale(ra(`xmn' `xmx')) xscale(noline)  



-----------------------------------
Thomas J. Steichen
steicht@rjrt.com
-----------------------------------
 
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Winter
Sent: Monday, February 19, 2007 3:02 PM
To: Stata List
Subject: st: Graph axis labelling range

Hi,

I am trying to create a "range-frame" around a scatterplot (see Tufte, 
Visual Display of Quantitative Information, pp 130-131).  The basic idea 
is that the axis line is drawn only for the range of the data.

I've managed to create it (for the y-axis only in this example) as follows:

.. sysuse auto

.. graph twoway scatter mpg price || ///
	scatteri 12 -250 41 -250, c(l) msym(none) , ///
	plotregion(margin(l 0  b 0)) yscale(noline) ///
	ylab(12 41, nogrid) xscale(ra(-200 15000)) ///
	legend(off) yscal(ra(10 45))

But this seems like a pretty ugly way to go (and requires some ad-hoc 
tinkering).

I'd have thought that the yscale(noextend) option would get me where I 
want to go, but this command:

.. graph twoway scatter mpg price , yscale(noextend)

draws a y-axis that runs from about 15.5 to 26.2.  Not sure why that's 
happening.

Is this something someone has programmed, or on which someone has a 
better approach?

Thanks
Nick Winter

-- 
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

-----------------------------------------
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:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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