This detail has been mentioned various times
on Statalist, so much so that somebody or
other will write a Tip on this for the
Stata Journal later this year. Or at least
it should be documented somewhere.
To attempt to gloss Nick's already full explanation,
the issue is that your -xscale()- specification is
not the only control. The documentation does make clear that
this is never going to override the limits of
the data. What doesn't seem so clear is that
-xscale()- can clash with -xlabel()-'s idea
of a reasonable default, in situations in
which you don't specify -xlabel()-.
To spell out this a little further:
if you specify -xscale()-
-- but do not specify -xlabel()- --
you are in effect saying to Stata "and please
use the default -xlabel()- for these data".
And that is precisely what it does.
So Stata is, contrary to all appearances,
doing its level best to do _precisely_ what
you asked it. Sometimes that is what you
expect, but not always.
What you are in effect expecting is that
Stata will have a default -xlabel()- for every
-xscale()- specification that's consistent
with the data. That's I think
a reasonable expectation on your part.
It's just not, it seems, the way that Stata works. I
suspect that there are deeper reasons for
that, to do with maximising the mutual
independence of different bits of code,
but there I am just guessing.
Incidentally, it took a conversation with
Patrick Royston for us both to realise a simple point, that
this issue is new in Stata 8. -graph- previously
had default labels of the minimum and maximum,
rather than the present attempts at nice
numbers (usually successful, although not
with a -log- scale).
Nick
[email protected]
Nick Winter
> This has confused me periodically, too.
>
> The issue is that the range of an axis can be expanded either
> by explicitly
> specifying a wider axis (with "xscale( range( ) )") or by
> specifying axis
> labels that include numbers outside the range of the data.
>
> By default, twoway defaults to labeling the axes with "about"
> 5 ticks, the
> equivalant of
>
> . scatter mpg price , xlabel(#5)
>
> and this will expand the range of the axis to make for round
> numbers. So
> you need to specify a narrower set of labels.
>
> . scatter mpg price , xlabel(minmax)
>
> . scatter mpg price , xlabel(2000 7000 15000)
>
> and so on.
Jonathan Falk
> >I am creating a scatterplot in which the minimum x value is 3.002 and
> >the maximum value is 9.29 (it comes from a larger dataset in which I
> >have dropped values larger than 10 or smaller than 3). When
> I create a
> >twoway scatter the displayed graph ranges from 2 to 10. I would like
> >the left-hand axis to start at 3, which will not cut off any
> data, but
> >the xaxis(range(3 10)) option doesn't seem to do the trick, as I
> >suspected it wouldn't since the documentation suggests that
> this command
> >only expands ranges. Suggestions?
*
* 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/