📄 twowaygraph_g.class
字号:
}
// 2 axes in a dim?
local right2 = (`.n_yaxes' + `:list sizeof ys') == 2
local top2 = (`.n_xaxes' + `:list sizeof xs') == 2
if `n_plreg' == 0 { // must have to position
.`log'.Arrpush .insert (plotregion1 = .plotregion.new, ///
style(scheme) graph(`.objkey')) at 1 1
}
tokenize `ypreg'
local i 0
foreach m of local ys {
local ++i
local pos = cond(`i'==1 & `right2' & ///
0`.style.y2axis_onright.istrue', "right", "left")
local axlook = cond(`m'==1, "vertical_default", ///
"vertical_nogrid")
if 0`.style.alt_yaxes.istrue' {
local pos = cond("`pos'"=="left", "right", "left")
}
if "`.yaxis`m'.isa'" != "" {
continue
// di as error "yaxis(`m') invalid, axis`m' already exists"
// exit 198
}
if (_caller() >= 8.2 & "`ys_dots`i''" != "") {
local ys_title`i'
local ys_dots`i'
.`log'.Arrpush local ys_title`i'
}
// push axis
.`log'.Arrpush ///
.insert (yaxis`m' = .axis.new , ///
plotregion(\`.``i''.objkey') ///
style(scheme `axlook') position(`pos') ///
title(\`ys_title`i''`ys_dots`i'')) ///
`pos'of plotregion1 , ring(`=`m'/10')
}
if "`rescaling'" == "" { // reset scales of any pre-existing axes
forvalues j=1/9 {
if "`.yaxis`j'.isa'" != "" {
.`log'.Arrpush .yaxis`j'.set_ticks
local ys `ys' `j'
}
}
}
tokenize `xpreg'
local i 0
foreach m of local xs {
local ++i
local pos = cond(`i'==1 & `top2' & ///
0`.style.x2axis_ontop.istrue', "above", "below")
local axlook = cond(`m'==1, "horizontal_default", ///
"horizontal_nogrid")
if 0`.style.alt_xaxes.istrue' {
local pos = cond("`pos'"=="below", "above", "below")
}
if "`.xaxis`m'.isa'" != "" {
continue
// di as error "xaxis(`m') invalid, axis`m' already exists"
// exit 198
}
.`log'.Arrpush ///
.insert (xaxis`m' = .axis.new, ///
plotregion(\`.``i''.objkey') ///
style(scheme `axlook') ///
position(`pos') ///
title(\`xs_title`i''`xs_dots`i'')) ///
`pos' plotregion1 , ring(`=`m'/10')
.`log'.Arrpush .``i''.addaxis \`.xaxis`m'.objkey'
// default fmts
.`log'.Arrpush local fmt = ///
cond(`"\`.xaxis`m'.plotregion.dimformat x'"' == `""', ///
`"\`.xaxis`m'.`ticknm'.label_format'"' , ///
`"\`.xaxis`m'.plotregion.dimformat x'"')
foreach tickset in major minor majornl minornl {
.`log'.Arrpush .xaxis`m'.`tickset'.label_format = `"\`fmt'"'
}
}
if "`rescaling'" == "" { // reset scales of any pre-existing axes
forvalues j=1/9 {
if "`.xaxis`j'.isa'" != "" {
.`log'.Arrpush .xaxis`j'.set_ticks
local xs `xs' `j'
}
}
}
.n_plotregions = `n_plreg'
.ParseAndLogAxes `log' 0 "" "`xs'" "`ys'" `goptions' // axes n such
_fr_legend_parse_and_log `log' `r(rest)'
if "`titling'" == "" { // titles
.parse_and_log_titles `log' "" `r(rest)'
.parse_and_log_spacers `log' "" `r(rest)'
}
else {
.parse_and_log_titles_edits `log' "" `r(rest)'
}
_fr_merged_implicit `log' BGColor ///
".bgcolor.setstyle , style(X)" , `r(rest)'
if `"`scale'"' != `""' {
.`log'.Arrpush .set_scale `scale'
}
// settings required for save/restore
.`log'.Arrpush .n_views = `.n_views'
.`log'.Arrpush .n_plotregions = `.n_plotregions'
.`log'.Arrpush .last_style = `.last_style'
forvalues j = 1/`.n_plotregions' {
local xscs `"`xscs' "`xscale`j''""'
local yscs `"`yscs' "`yscale`j''""'
}
.`log'.Arrpush .x_scales = `"`xscs'"'
.`log'.Arrpush .y_scales = `"`yscs'"'
// text
.x_scales = `"`xscs'"'
.y_scales = `"`yscs'"'
if `"`r(rest)'"' != `""' {
.ParseAndLogText `log' , `r(rest)'
}
local 0 `", `r(rest)'"'
syntax [, FAKE_OPT_FOR_BETTER_MSG ]
_fr_runlog `log' , `logging'
end
program ParseOpts
gettoken xmac 0 : 0
gettoken ymac 0 : 0
gettoken sermac 0 : 0
gettoken omac 0 : 0
gettoken colon 0 : 0
gettoken plreg 0 : 0
syntax [ , XAXis(numlist integer sort >0 <10) ///
YAXis(numlist integer sort >0 <10) SERSET(string) * ]
if `"`plreg'"' != `""' {
if "`xaxis'`yaxis'" != "" {
di as error "may not combine xaxis() or yaxis() with" ///
" useplotregion() or add"
exit 198
}
}
if "`xaxis'" == "" {
local xaxis 1
}
else {
foreach tok of local xaxis { // reverse
local r `tok' `r'
}
local xaxis `r'
}
if "`yaxis'" == "" {
local yaxis 1
}
else {
local r
foreach tok of local yaxis { // reverse
local r `tok' `r'
}
local yaxis `r'
}
c_local `xmac' `xaxis'
c_local `ymac' `yaxis'
c_local `sermac' `serset'
c_local `omac' `options'
end
program SetCheckPlotregion
args plmac colon plotregion add
if `"`plotregion'`add'"' == `""' {
exit
}
if "`add'" != "" {
if `"`plotregion'"' != "" {
di as error "may not combine optons add and plotregion()"
exit 198
}
_cls nameoflocal dynamicmv[1]
local plotregion `r(name)'
}
if ! 0`.`plotregion'.isofclass plotregion' {
di as error `"`plotregion' is not a plotregion"'
exit 198
}
c_local `plmac' `plotregion'
end
// ---------------------------------------------------------------------------
program ParseAndLogText , rclass
gettoken log 0 : 0
syntax [ , TEXT(string asis) TTEXT(string asis) * ]
while `"`text'`ttext'"' != `""' {
if `"`text'"' != "" {
._parse_log_1textbox `log' "" `text'
}
if `"`ttext'"' != "" {
._parse_log_1textbox `log' "datesok" `ttext'
}
local 0 `", `options'"'
syntax [ , TEXT(string asis) TTEXT(string asis) * ]
}
return local rest `"`options'"'
end
program _parse_log_1textbox
gettoken log 0 : 0
gettoken datesok 0 : 0
syntax [ anything(name=triplets) ] [ , AXes(string) ///
YAXis(integer 1) XAXis(integer 1) TSTYle(string) * ]
local fullopts `"`options'"'
if `"`tstyle'"' == `""' {
local tstyle "scheme text_option"
}
// get axis numbers
if `"`axes'"' != `""' {
if `:list sizeof axes' != 2 {
di as error "invalid axes(`axes')"
exit 198
}
gettoken yaxis xaxis : axes
foreach d in y x {
if "``d'axis'" == "." {
`d'axis = 1
}
}
}
// find the plotregion
local j 0
foreach yscl in `.y_scales' {
local ++j
if "`:list yscl & yaxis'" != "" {
local xscl : word `j' of `.x_scales'
local xscl `xscl' // sic
if "`:list xscl & xaxis'" != "" {
local plreg plotregion`j'
continue , break
}
}
}
if "`plreg'" == "" {
di as error "text() option invalid, specified axis " ///
"pair (`yaxis' `xaxis') not in graph"
exit 198
}
// Insert the textboxes
gettoken y triplets : triplets
gettoken x triplets : triplets
while `"`y'"' != `""' {
capture numlist "`x' `y'" , max(2) min(2) // x-y point
local rc = _rc
if `rc' & "`datesok'" != "" {
capture {
numlist "`y'" , max(1) min(1)
_confirm_number_or_date `x'
}
local rc = _rc
}
if `rc' {
di as error `"invalid point, `x' `y'"'
exit 198
}
gettoken txtq triplets : triplets , quotes // text
gettoken txt : txtq
while `"`txtq'"' != `""' & `"`txtq'"' != `"`txt'"' {
local mtext `"`mtext' `txtq'"'
gettoken txtq triplets : triplets , quotes
gettoken txt : txtq
}
.n_text = `.n_text' + 1
// pass the format indirectly to the textbox
if "`datesok'" != "" {
local dopt datesok(\`tfmt')
}
.`log'.Arrpush local tfmt \`.`plreg'.get_time_format'
.`log'.Arrpush .`plreg'.Declare textbox`.n_text' = ///
.pos_textbox.new , ypos(`y') xpos(`x') ///
forcesized mtext(`mtext') style(`tstyle') ///
`macval(dopt)'
local mtext
_fr_sztextbox_parse_and_log `log' `plreg'.textbox`.n_text' ///
, `fullopts'
local 0 `", `r(rest)'"'
syntax [, FAKE_OPT_FOR_BETTER_MSG ]
local y `txt'
gettoken x triplets : triplets
}
end
// ---------------------------------------------------------------------------
program _unab_cmd
args cmac colon cmd
local 0 , `cmd'
syntax [ , SCatter LIne CONnected HISTogram RSCatter RLine ///
RCONnected MBANDs FN FUNction *]
if "`fn'" != "" {
c_local `cmac' function
exit
}
c_local `cmac' `scatter' `line' `connected' `histogram' ///
`rscatter' `rline' `rconnected' ///
`mbands' `function' `options'
end
// ---------------------------------------------------------------------------
// Returns the number of the next default series style and updates that number
program next_default_series
.last_style = `.last_style' + 1
class exit = `.last_style'
end
// ---------------------------------------------------------------------------
// Return the number of y/xaxes. Note, just because this is 3 does not mean
// they are named yaxis1, yaxis2, yaxis3; the numbers may not be dense.
program n_yaxes
local n = 0
forvalues i=1/9 {
if "`.yaxis`i'.isa'" != "" {
local ++n
}
}
class exit = `n'
end
program n_xaxes
local n = 0
forvalues i=1/9 {
if "`.xaxis`i'.isa'" != "" {
local ++n
}
}
class exit = `n'
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -