Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: How to place text inside a bar chart / Stata 8 SE -win2k

From   May Boggess <>
Subject   Re: st: RE: How to place text inside a bar chart / Stata 8 SE -win2k
Date   24 Jul 2003 15:30:22 -0500

Dr. Wolfram asked about how to put test on a bar graph:

> > I have produced the following simple bar chart:
> >
> > graph bar (asis) exper contrl, over(task) .....
> >
> > Now the problem: I would like to insert some explanatory
> > text inside the
> > graph with the added_text_option:
> >
> > text(#y #x "text")
> >
> > Unfortunately, as this is not a two-way graph #x will be
> > ignored. How can I
> > locate a text box relative to one of the 6 specific 'task' bars?

Nick Cox responded with the following suggestion:

> You can make progress by adding
> legend(on order(- "text") ring(0) pos(12))
> but whether that gets you all the way I don't know.
> Alternatively, use -twoway bar-.

The option text (#y #x "text") does work with -graph bar-
(check page 118, graphics manual).
Stata interprets the number #y in the units used on the y-axis.

The manual says the number #x is to be in the range 0-100, and I suppose
this is a percentage of the width of the graph. Perhaps Dr. Wolfram did
not notice this because the various x values he tried may not have
been sufficiently different to produce a noticable effect on his graph.

The point to note here is that -text()- works differently with 
-graph bar- that with -twoway- because, as Nick Cox pointed out,
-graph bar- does not have an x-axis. On graphs which do have
an x-axis, the number #x in -text(#y #x "text")- is interpreted by 
Stata in the units used on the x-axis (see page 19, graphics manual).

The following example may be helpful:

  . sysuse educ99gdp
  . drop if _n>6
  . graph bar (asis) public private, over(country) text(0.8 10 "text")
  . graph bar (asis) public private, over(country) text(1.25 90 "text")

-- May

*   For searches and help try:

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