Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Fwd: Changing the yaxis for multiple graphs generated with "graph box" with a "by"


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Fwd: Changing the yaxis for multiple graphs generated with "graph box" with a "by"
Date   Wed, 9 Oct 2013 18:42:39 +0100

How to get separate scales is well documented, e.g.

. sysuse auto
. graph box price, by(rep78, rescale)
. graph hbox price, by(rep78, rescale)

What takes a little getting used to is that the suboption required
belongs with -by()-.

As for your complaint that Stata ignores the -yscale()- option: consider this

. graph hbox price, by(rep78) ysc(ra(30000 0))

Stata certainly pays attention in this case. I guess your problem is
that you have prices outside (-1,1).

Incidentally, What does a price of -1 mean any way? You pay me to take
your product away?

Regardless of that, Stata won't let you use -ysc()- to contract the
range of what is shown, i.e. to omit values.

All that said, it is difficult to see the merit in different scales
for a comparative graph. Perhaps you could think about using a
transformed scale which subdues the outliers appropriately.

Nick
njcoxstata@gmail.com


On 9 October 2013 18:27, Ludovico Zaraga <ludovico.zaraga@gmail.com> wrote:

> I have a large dataset where I have a distribution of prices for a
> number of countries. I display this graphically with the following
> command:
>
> graph box prices, by(Country)
>
> The issue is that some countries have some outliers which make so that
> the yaxis goes to very large values. While this is not an issue for
> the few countries with outliers, the command above uses the same yaxis
> for all the graphs shown.
>
> Ideally I would like each "Country" graph shown to have a yaxis
> spanning the minimum and maximum for that specific country, instead of
> the min/max over all countries as stata does.
>
> A less ideal solution, would be to change the yaxis for all graphs
> plotted. I tried the following to do this:
>
> graph box prices, by(Country) yscale(range(-1,1))
>
> but stata ignores the yscale option completely.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index