Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: marginsplot


From   Melvyn Weeks <mw217@cam.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: marginsplot
Date   Fri, 05 Oct 2012 14:12:14 +0100

Many thanks for this Tirthankar

Melvyn

On 03/10/2012 11:58, Tirthankar Chakravarty wrote:
You have a few options:

1) You can change the Stata graph scheme to something like "s2mono" so
that graphs are appropriate for B&W printing. For example:

*------------------------------------------------
use http://fmwww.bc.edu/ec-p/data/wooldridge/wagepan, clear
xtset nr year
xtreg lwage exper educ union hisp black ///
         i.married##i.year, fe

set scheme s2mono
margins, over(married year)
marginsplot, xdimension(year) ///
         plotdimension(married)  xlabel(, angle(90))
*------------------------------------------------


2) Or you can manually change the marker symbols of each of the -by-
dimensions of your plot using standard -twoway- plot options. This is
tedious but allows you greatest control (continuing the previous
example):

*------------------------------------------------
xtreg lwage exper educ union hisp black ///
         i.married##i.year, fe
set scheme s2color

margins, over(married year)
marginsplot, xdimension(year)  ///
         plotdimension(married) ///
		plot1opts(msymbol(D))  /// marker for first line
		plot2opts(msymbol(Oh)) // marker for second line
  *------------------------------------------------

See  [G-4] symbolstyle for a full list of available marker styles.

3) You can automate this process using the -levelsof- the -by-
variable and iteratively constructing the plot options, as in this
example:

*------------------------------------------------
sysuse auto, clear
reg mpg i.foreign##c.(rep78 headroom trunk weight)

qui levelsof foreign, local(levels)  // -levelsof- -by- variable
local markerlist "O d p o"  // a list of marker styles
local optioncount 1  // begin with first plot line
foreach level of local levels {
	if("`markerlist'" ~="") local markeroption: ///
		word 1 of `markerlist'
	else {
		di "Out of marker styles!"
	}
	local markerlist: list markerlist - markeroption
	local plotoptions ///
		"`plotoptions' plot`optioncount'opts(msymbol(`markeroption'))"
	local ++optioncount
}
di "`plotoptions'"  // check plot options are correctly formed
margins, dydx(*) over(foreign)
marginsplot, xdim(_deriv) `plotoptions'
*------------------------------------------------

T



On Wed, Oct 3, 2012 at 2:12 PM, Melvyn Weeks <mw217@cam.ac.uk> wrote:
I am using marginsplot, and displaying multiple plots on one graph.

How do I control whether points are displayed as circles, triangles,
squares ...

The default seem to be that all points are circles which is not so good
on a black and white printer

Thanks
Melvyn

--
Dr. M. Weeks
Senior Lecturer in Economics
University of Cambridge

Fellow of Clare College

t. (+44) 01223 335260
f. (+44) 01223 335959

e.        mw217@econ.cam.ac.uk

w.        http://www.econ.cam.ac.uk/faculty/

DCM V2.0  http://www.econ.cam.ac.uk/DCM2/




*
*   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/
*
*   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/


--
Dr. M. Weeks
Senior Lecturer in Economics
University of Cambridge

Fellow of Clare College

t. (+44) 01223 335260
f. (+44) 01223 335959

e.        mw217@econ.cam.ac.uk

w.        http://www.econ.cam.ac.uk/faculty/

DCM V2.0  http://www.econ.cam.ac.uk/DCM2/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index