轴在多条线上断开时偏离中心

Amb*_*lis 8 stata

我正在使用graph twoway scatter并添加自己的ylabels.

我经常有很长的标签并将它们分成多行.但是,我遇到一个问题,当我想打破一些在两行的标签,而不是其他.

当我这样做时,单线标签相对于它们的tick标记是偏心的,就像Stata期望它们也有两条线一样.

请参阅下面的简单说明:

sysuse auto, clear

/* This graph has one long label and one short but both are off-center 
relative to their tick marks */

twoway scatter length weight, ytitle("") ylabel(220 ///
`" "This one is a very long" "label, broken up" "' 140 "This one is not", ///
ang(horizontal))

/* The order of labels on the graph *does not* appear to matter */

twoway scatter length weight, ytitle("") ylabel(180 ///
`" "This one is a very long" "label, broken up" "' 220 "This one is not", ///
ang(horizontal))

/* But the order in the command *does* appear to matter */

twoway scatter length weight, ytitle("") ylabel(220 ///
"This one is not" 140 `" "This one is a very long" "label, broken up" "', ///
ang(horizontal))
Run Code Online (Sandbox Code Playgroud)

这不是一个大问题,但我已经注意了多年并且知道为什么我的图表以这种方式表现会很好.

Pea*_*cer 18

目前尚不清楚究竟是什么造成了这种情况,但人们可以做出有根据的猜测.

看来,如果你改变你的代码,包括所有stringsdouble quotes,问题消失.使用你的玩具示例:

sysuse auto, clear

twoway scatter length weight, name(gr1) ytitle("") ylabel(220 ///
`" "This one is a very long" "label, broken up" "' 140 `" "This one is not" "', ///
ang(horizontal))

twoway scatter length weight, name(gr2) ytitle("") ylabel(180 ///
`" "This one is a very long" "label, broken up" "' 220 `" "This one is not" "', ///
ang(horizontal))

twoway scatter length weight, name(gr3) ytitle("") ylabel(220 ///
`" "This one is not" "' 140 `" "This one is a very long" "label, broken up" "', ///
ang(horizontal))
Run Code Online (Sandbox Code Playgroud)

这可能与内部解析代码的方式有关,并建议Stata期望第二个string引号的数量与第一个相同.

只有StataCorp才能明确回答您的问题,但希望上面的示例能为您提供有关正在发生的事情的线索.