Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: colouring options of serrbar

 From Nick Cox <[email protected]> To [email protected] Subject Re: st: colouring options of serrbar Date Wed, 28 Sep 2011 21:27:05 +0100

```-serrbar- is really only a token command for plotting error bars. (I
am rather generously credited in at least some versions of the manual
with some responsibility for it only because I suggested some
extensions a long time ago, but it was born an official command and
remains one.)

It's better to back-track to the premise that you have

mvar
svar
xvar

For simplicity, suppose that you want your bars to go from mvar - 1 *
svar to mvar + 1 * svar. In your real problem you can generalise that
multiplier of 1 to what you want (even a variable).

Then first calculate

gen lvar = mvar - svar
gen uvar = mvar + svar

Now you can go

twoway scatter mvar xvar || rcap lvar uvar xvar

Now you can extend this however you want

twoway scatter mvar xvar if group == 1, ms(pink) || rcap lvar uvar
xvar if group == 1, lc(pink)
scatter mvar xvar if group == 2, ms(blue) || rcap lvar
uvar xvar if group == 2, lc(blue)

and so on. In practice, put this code in the do-file editor, use lots
of lines and /// to connect lines.

-search statsby- for another useful approach and an article on that.

Nick

On Wed, Sep 28, 2011 at 8:53 PM, Truus F. Hausman
<[email protected]> wrote:

> I am struggling with the colouring options of serrbar. I would like to
> colour groups of markers and change the style of error bars.
> Specifically, I have got three different estimates from 20 countries
> (e.g. from three different years or three different estimators). The
> countries form the x-axis, at each unit of the x-axis there are three
> estimates. Now, I would like to colour those estimates that stem from
> the same group (i.e. the same estimator or year). So far I am unable
> to find a solution. I tried two different approaches:
>
> a) conditions in mvopts
> serrbar mvar svar xvar, mvopts(mcolor(black if group==1, blue if group==2
>
> serrbar mvar svar xvar if group==1, mvopts(mcolor(black))
> addplot(serrbar mvar svar xvar if group==2, mvopts(mcolor(blue)))
>
> Both do not work. The first does not change the colour of the markers,
> the second is not allowed ("serrbar is not a twoway plot type"
> r(198)).
>
> Has anyone an idea how I can change the colour of the markers and
> maybe also the style of the error bars? Or will I have to use a
> different type of graph?
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```