Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Bar graph: problem with category labels


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Bar graph: problem with category labels
Date   Thu, 26 Jul 2007 17:31:51 -0500

Friedrich Huebler <fhuebler@gmail.com> writes,

> When a two-line category label is added to a -graph hbar, over()-
> horizontal bar graph, the labels above the two-line label are no
> longer centered next to the bars. This happens in Stata versions 8,
> 9 and 10.
>
> . sysuse auto
> . graph hbar mpg trunk, over(rep78)
> . graph hbar mpg trunk, over(rep78, relabel(3 "One line"))
> . graph hbar mpg trunk, over(rep78, relabel(3 `""Two" "lines""'))
> . graph hbar mpg trunk turn, over(rep78, relabel(3 `""Two" "lines""'))
>
> In the first two graphs all category labels are centered next to the
> bars. In the third and fourth graph the labels for the first two
> categories are shifted up along the vertical axis.
>
> How can all category labels be centered next to the bars?

Pages of explanation would not make this clear.  Better to run the commands
Friedrich supplied and see the problem for yourself.

Scott Merryman <scott.merryman@gmail.com> came up with what Friedrich
rightly calls an "amazing" solution.

   . graph hbar mpg trunk, over(rep78, ///
     relabel(1 `"" "" ""1"" "" ""' 2 `"" "" ""2"" "" ""' 3 `""Two" "lines""'))

Scott basically forced the correct alignment of labels by throwing a pair of
blank lines around each default label that was displaying one row higher than
center.

Scott's creative solution notwithstanding, this looks like a bug to me and one
that we will fix in the next ado updates.



-- Vince 
   vwiggins@stata.com

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index