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]

st: RE: RE: ADO file to graph using features of the default scheme


From   "Brent McSharry" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: ADO file to graph using features of the default scheme
Date   Thu, 12 Aug 2010 18:33:17 +1200

A belated thank you for your useful reply Mr Cox:

somehow i had read the manual incorrectly, and had been caught up in the documentation regarding how to set the scheme files, and thus "couldn't see the wood for the trees"! the pstyle option definately has all the functionality I need for this ado file.

the line pattern was the only thing which I wished to force from the nominated scheme. For those who encounter the same problem, the eventual code ended up something like:

local linepatmac dash dot dash_dot shortdash shortdash_dot longdash longdash_dot solid solid solid
forvalues ` i'  = 2/`novars' {
/// novars = macro containing number of variables in varlist - 1st variable is dependant variable
   ...
   local styleno = `i' - 1
   local linepat: word `styleno' of `linepatmac'
local scatterstr `scatterstr' (scatter `meanobs`i'' `meanexp`i'', pstyle(p`styleno') m(`symb')) local linestr `linestr' (line `bestfit`i'' `meanexp`i'', pstyle(p`styleno') lwidth(thin) lpattern(`linepat')) local civstr `civstr' (rcap `ubv`i'' `lbv`i'' `meanexp`i'', pstyle(p`styleno')) local lblstr (scatter `meanobs`i'' `meanexp`i'', pstyle(p`styleno') mlabel(`totobs`i'') mlabp(12) m(i))
}
twoway `scatterstr' `linestr' `cihstr' `civstr' `lblstr'

Date: Sun, 9 May 2010 19:07:27 +0100
From: "Nick Cox" <[email protected]>
Subject: st: RE: ADO file to graph using features of the default scheme

The current scheme is detectable as c(scheme).

Even so, this doesn't seem especially easy as many scheme definitions
just signal variations from some named scheme, so you'd need to look
beyond the scheme file defining c(scheme) in many cases.

My attitude tends to be Olympian here. I don't feel any guilt in
choosing colours as program writer so long as users have hooks to change
them to what they wish.

Evidently you know about [G] pstyle.

Nick
[email protected]

Brent McSharry

I am using Stata/IC 10.1 for Windows.

I am writing an .ado program in which several models are plotted  on a
twoway graph, plotting each model's observed against expected outcome,
divided into quantiles of risk (a graphical hosmer lemeshow goodness of
fit - displaying 1 or more models) . Each model will have a scatter
markers,
rcap (denoting confidence interval), line (of best fit, frequency
weighted)
and label (stating the number of observations in that quantile). Thus 3
different plot types are associated with each model. I would like each
model
(and the associated 3 different plot types + marker label) to have the
same
color, and each new model to have a different colour (or grayscale) for
all
of its associated plot types.

One solution I can see is to create a macro with the names of the colors
to
cycle through (for each model), and assign the same color option in turn
to
each plot type eg:
local colorcycle red blue green ...
forvalues i=1/`novars' {
   local coloroption: word `i'  of `colorcycle'
   local scatmac `scatmac' (scatter..., mcolor(`coloroption'))
   local rcapmac `rcapmac' (rcap..., lcolor(`coloroption'))
   }

Another is to create a scheme file with the same colours in turn for
each
plot type eg:
p1line red
p2line blue
p1scatter red
p2scatter blue

However, either option will negate the users default scheme (and the
second
option is not as useful for distributing the ado file to other users).
Is
there any way in Stata to find the color p1 p2 p3 etc in the scheme
which is
active at the time of execution of an ado file?

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