断开多条线时,轴标签偏离中心 [英] Axis labels off-center when broken over multiple lines
本文介绍了断开多条线时,轴标签偏离中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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))
这不是一个大问题,但我已经注意到这个问题很多年了,知道我的图表为什么会这样就好了。
推荐答案
不清楚到底是什么原因造成的,但可以根据知识进行猜测。
看起来,如果您更改代码以包含double quotes
中的所有strings
,问题就会消失。使用您的玩具示例:
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))
这可能与代码的内部解析方式有关,并表明Stata希望第二个string
与第一个string
具有相同数量的引号。
只有StataCorp可以明确回答您的问题,但希望上面的示例能为您提供有关情况的线索。
这篇关于断开多条线时,轴标签偏离中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文