📄 twoway_yxview_parse.class
字号:
to(area(linestyle(pattern(X))))
_parse combop 0 : 0 , option(BLWidth) rightmost
_parse factor 0 : 0 , option(BLWidth) to(area(linestyle(width(X))))
// area fill synonym, no prefix
_parse combop 0 : 0 , option(FColor) rightmost
_parse factor 0 : 0 , option(FColor) to(area(shadestyle(color(X))))
_parse combop 0 : 0 , option(FIntensity) rightmost
_parse factor 0 : 0 , option(FIntensity) ///
to(area(shadestyle(intensity(X))))
// dot marker options
_parse combop 0 : 0 , option(DSTyle) rightmost
_parse factor 0 : 0 , option(DSTyle) to(dots(X))
_parse combop 0 : 0 , option(Dsymbol) rightmost
_parse factor 0 : 0 , option(Dsymbol) to(dots(symbol(X)))
_parse combop 0 : 0 , option(DColor) rightmost
_parse factor 0 : 0 , option(DColor) ///
to(dots(fillcolor(X) linestyle(color(X))))
_parse combop 0 : 0 , option(DFColor) rightmost
_parse factor 0 : 0 , option(DFColor) to(dots(fillcolor(X)))
_parse combop 0 : 0 , option(DSIze) rightmost
_parse factor 0 : 0 , option(DSIze) to(dots(size(X)))
_parse combop 0 : 0 , option(DLstyle) rightmost
_parse factor 0 : 0 , option(DLstyle) to(dots(linestyle(X)))
_parse combop 0 : 0 , option(DLColor) rightmost
_parse factor 0 : 0 , option(DLColor) to(dots(linestyle(color(X))))
_parse combop 0 : 0 , option(DLPattern) rightmost
_parse factor 0 : 0 , option(DLPattern) ///
to(dots(linestyle(pattern(X))))
_parse combop 0 : 0 , option(DLWidth) rightmost
_parse factor 0 : 0 , option(DLWidth) to(dots(linestyle(width(X))))
class exit `"`0'"'
end
program FactorPlot
_parse combop 0 : 0 , option(Type) rightmost
_parse factor 0 : 0 , option(Type) to(type(X))
_parse combop 0 : 0 , option(Connect) rightmost
_parse factor 0 : 0 , option(Connect) to(connect(X))
_parse combop 0 : 0 , option(CMISSings) rightmost
_parse factor 0 : 0 , option(CMISSings) to(cmissings(X))
_parse combop 0 : 0 , option(JITTER) rightmost
_parse factor 0 : 0 , option(JITTER) to(jitter(X))
_parse combop 0 : 0 , option(JITTERSEED) rightmost
_parse factor 0 : 0 , option(JITTERSEED) to(jitterseed(X))
_parse combop 0 : 0 , option(YVARLabel) rightmost
_parse factor 0 : 0 , option(YVARLabel) to(yvarlabel(X))
_parse combop 0 : 0 , option(XVARLabel) rightmost
_parse factor 0 : 0 , option(XVARLabel) to(xvarlabel(X))
_parse combop 0 : 0 , option(YVARFormat) rightmost
_parse factor 0 : 0 , option(YVARFormat) to(yvarformat(X))
_parse combop 0 : 0 , option(XVARFormat) rightmost
_parse factor 0 : 0 , option(XVARFormat) to(xvarformat(X))
_parse combop 0 : 0 , option(NUMKEYs) rightmost
_parse factor 0 : 0 , option(NUMKEYs) to(numkeys(X))
if `.BarOrBarDerived' {
_parse combop 0 : 0 , option(BARType) rightmost
_parse factor 0 : 0 , option(BARType) to(bartype(X))
_parse combop 0 : 0 , option(BARWidth) rightmost
_parse factor 0 : 0 , option(BARWidth) to(barwidth(X))
_parse combop 0 : 0 , option(DROPto) rightmost
_parse factor 0 : 0 , option(DROPto) to(dropto(X))
_parse combop 0 : 0 , option(BARGap) rightmost
_parse factor 0 : 0 , option(BARGap) to(bargap(X))
_parse combop 0 : 0 , option(BASE) rightmost
_parse factor 0 : 0 , option(BASE) to(base(X))
_parse combop 0 : 0 , option(DOTEXtend) rightmost
_parse factor 0 : 0 , option(DOTEXtend) to(dotextend(X))
_parse combop 0 : 0 , option(NDOTs) rightmost
_parse factor 0 : 0 , option(NDOTs) to(ndots(X))
}
class exit `"`0'"'
end
/* -------------------------------------------------------------------------*/
/*
Logs a command or commands to create a new serset and the view and
returns its reference. Assumes that the data in memory is the same as
when parse was called.
Allows a touse(varname) option that further restricts the sample,
restricts beyond the held .if and .in
Additional options to the .serset.new command may be specified, but
this is unlikely to be necessary.
If must_create_serset == 1, then this command MUST be used,
otherwise the serset may be created by other means.
*/
program log_create_serset
syntax , LOG(name) SERSETNAME(string) [ TOUSE(passthru) * ]
.log_touse , log(`log') `touse'
if "`.sort'" != "" {
local sortopt sort(`.sort')
}
.`log'.Arrpush .`sersetname' = .serset.new `.varlist' ///
[`.wtype'`.wtexp'] if \`touse1' , `.omitmethod' ///
`sortopt' `options' nocount
if "`.wtype'" != "" {
.wtvarnum = `=`:word count `.varlist''+1'
}
end
program log_touse
syntax , LOG(name) [ TOUSE(varname) ]
.`log'.Arrpush __NOLOG__ tempname touse1
// caller agrees to use touse1
if "`touse'" == "" {
.`log'.Arrpush __NOLOG__ gen byte \`touse1' = 1
}
else {
.`log'.Arrpush __NOLOG__ gen byte \`touse1' = `touse'
}
if `"`.in'`.if'"' != "" {
.`log'.Arrpush __NOLOG__ tempname touse2
.`log'.Arrpush __NOLOG__ mark \`touse2' `.if' `.in'
.`log'.Arrpush __NOLOG__ ///
qui replace \`touse1' = 0 if \`touse2' != 1
}
end
program full_touse
args touse newtouse
// like log_touse, but immediately affects the
// supplied newtouse variable.
// caller agrees to use touse1
if "`touse'" == "" {
capture gen byte `newtouse' = 1
if _rc {
replace `newtouse' = 1
}
}
else {
capture gen byte `touse1' = `touse'
if _rc {
replace `newtouse' = `touse'
}
}
if `"`.in'`.if'"' != "" {
tempname touse2
mark `touse2' `.if' `.in'
qui replace `newtouse' = 0 if `touse2' != 1
}
end
/* -------------------------------------------------------------------------*/
/*
Logs a command to create an instance of the view.
Expects to see a serset(serset_name|serset_reference) option.
Additional options to the .new command may be specified.
seriesid(#) is an option to log_create_view that specifies a default
series scheme for the view that will be used if the style option was
not specified.
*/
program log_create_view
syntax , LOG(name) NAME(name) PLOTREGion(string) SERSET(string) ///
[ View(integer 1) SERIESID(integer 0) style(string) ///
YVARiable(passthru) XVARiable(passthru) ///
LVARiable(passthru) WVARiable(passthru) * ]
if ("`yvariable'"=="" | "`xvariable'"=="" | "`wvariable'"=="") ///
& (`view' > `.n' | `.n' >= .) {
di as error "twoway_yxview_parse, view # too large"
exit 198
}
if `"`style'"' == "" {
if `seriesid' > 0 {
local styleopt style(scheme p`seriesid'`._type_suffix')
}
else {
local styleopt style(scheme)
}
}
else {
local styleopt style(`style')
}
tokenize `.varlist'
if `"`yvariable'"' == `""' {
local yvariable yvariable(\`.`serset'.seriesof ``view''')
}
if `"`xvariable'"' == `""' {
local xvariable xvariable(\`.`serset'.seriesof ``=`.n'+1''')
}
if `"`lvariable'"' == `""' {
if "`.labvars[`view']'" != "" {
local lvariable ///
lvariable(\`.`serset'.seriesof `.labvars[`view']'')
}
}
if `"`pvariable'"' == `""' {
if "`.posnm'" != "" {
local pvariable ///
pvariable(\`.`serset'.seriesof `.posnm'')
}
}
if `"`wvariable'"' == `""' {
if `"`.wtexp'"' != `""' {
local wvariable wvariable(0\`.`serset'.weight_id')
}
}
.`log'.Arrpush .`plotregion'.Declare `name' = .`.viewclass'.new , ///
type(`.viewtype') serset(\`.`serset'.objkey') ///
`macval(yvariable)' `macval(xvariable)' `macval(wvariable)' ///
`macval(lvariable)' `macval(pvariable)' ///
plotregion(\`.`plotregion'.objkey') ///
`styleopt' `macval(options)'
end
program define _type_suffix
if ("`.viewtype'" == "line" | "`.viewtype'" == "rline" | ///
"`.viewtype'" == "pcline") class exit "line"
if ("`.viewtype'" == "bar" | "`.viewtype'" == "rbar") class exit "bar"
if ("`.viewtype'" == "area" | "`.viewtype'" == "rarea") class exit "area"
if ("`.viewtype'" == "pcarrow" | "`.viewtype'" == "pcbarrow") ///
class exit "arrow"
end
/* -------------------------------------------------------------------------*/
/*
Pushes onto the specified log any post-creation commands implied by
the parsed syntax that must be applied to the created view.
*/
program log_edits
args log view i novlabel
if `"`.plotstyles[`i']'"' != `""' {
.`log'.Arrpush .`view'.style.editstyle `.plotstyles[`i']' ///
editcopy // should unamed styles be the default
}
if `"`.plotsettings[`i']'"' != `""' {
local 0 `", `.plotsettings[`i']'"'
syntax [ , TYPE(string) CONNECT(string) CMISSINGS(string) ///
JITTER(real 0) JITTERSEED(integer -1) ///
YVARLABEL(string asis) XVARLABEL(string asis) ///
YVARFORMAT(string) XVARFORMAT(string) ///
NUMKEYS(string) * ]
if `"`type'"' != `""' {
.`log'.Arrpush .`view'.type.setstyle , style(`type')
}
if `"`connect'"' != `""' {
.`log'.Arrpush .`view'.style.editstyle ///
connect(`connect') editcopy
.`log'.Arrpush .`view'._maybe_override_type
}
if `"`cmissings'"' != `""' {
.`log'.Arrpush ///
.`view'.style.editstyle ///
connect_missings(`cmissings') editcopy
}
if `jitter' != 0 {
.`log'.Arrpush .`view'.jitter = `jitter'
if `jitterseed' <= 0 {
.`log'.Arrpush .`view'.jitterseed = ///
`gdi(newjitterseed)'
}
else {
.`log'.Arrpush .`view'.jitterseed = ///
2*(`jitterseed'/2) + 1
}
}
if "`novlabel'" == "" {
if `"`yvarlabel'"' != `""' {
local yvarlabel `yvarlabel' // sic
.`log'.Arrpush ///
.`view'.serset.sers[\`.`view'.yvar'].label = ///
`"`yvarlabel'"'
}
if `"`xvarlabel'"' != `""' {
.`log'.Arrpush ///
.`view'.serset.sers[\`.`view'.xvar'].label = ///
`"`xvarlabel'"'
}
}
if `"`yvarformat'"' != `""' {
.`log'.Arrpush ///
.`view'.serset.sers[\`.`view'.yvar'].format = ///
`"`yvarformat'"'
}
if `"`xvarformat'"' != `""' {
.`log'.Arrpush ///
.`view'.serset.sers[\`.`view'.xvar'].format = ///
`"`xvarformat'"'
}
}
if (`.BarOrBarDerived') .LogBarEdits `log' `view' `i' `options'
if `.drop_base' == 0 {
.`log'.Arrpush .`view'.drop_base.setstyle , style(no)
}
if `"`numkeys'"' != `""' {
.`log'.Arrpush .`view'.numkeys = `numkeys'
}
end
program LogBarEdits
gettoken log 0 : 0
gettoken view 0 : 0
gettoken i 0 : 0
if "`.overall_drop_to'" != "" {
.`log'.Arrpush .`view'.bar_drop_to.setstyle , ///
style(`.overall_drop_to')
}
if `"`0'"' != `""' {
local 0 , `0'
syntax [ , BASE(string) ///
BARTYPE(string) BARWIDTH(real -1) ///
BARGAP(real -1) DROPTO(string) ///
DOTEXTEND(string) NDOTS(real -1) ]
if `"`base'"' != `""' {
capture confirm number `base'
if _rc {
di as error "option base() incorrectly specified" ///
", `base' is not a number"
}
.`log'.Arrpush .`view'.base = `base'
}
if `"`bartype'"' != `""' {
.`log'.Arrpush .`view'.bartype.setstyle , ///
style(`bartype')
}
if `barwidth' != -1 {
.`log'.Arrpush .`view'.bar_size = `barwidth'
}
if `bargap' != -1 {
.`log'.Arrpush .`view'.bar_gap = `bargap'
}
if `"`dropto'"' != `""' {
.`log'.Arrpush .`view'.bar_drop_to.setstyle , ///
style(`dropto')
}
if "`dotextend'" != "" {
.`log'.Arrpush .`view'.dots_extend.setstyle ///
, style(`dotextend')
}
if `ndots' != -1 {
.`log'.Arrpush .`view'.num_dots = `ndots'
}
}
.`log'.Arrpush .`view'.register_with_scale
end
/* -------------------------------------------------------------------------*/
/* Returns the value of the specified plot-level option for the the
specified view number. Returns the string representation of the option.
*/
program plotoption
args option i
if `"`.plotsettings[`i']'"' != `""' {
local 0 `", `.plotsettings[`i']'"'
syntax [ , `option'(string asis) * ]
if `"``option''"' != `""' {
class exit `"``option''"'
}
}
end
// ---------------------------------------------------------------------------
program BarOrBarDerived
class exit = ("`.viewtype'" == "bar" | ///
"`.viewtype'" == "area" | ///
"`.viewtype'" == "dot" | ///
"`.viewtype'" == "dropline" | ///
"`.viewtype'" == "scatteri" | ///
"`.viewtype'" == "spike")
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -