Statalist


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

Re: st: how to remove axis margin from plot


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   Re: st: how to remove axis margin from plot
Date   Fri, 13 Feb 2009 12:51:55 -0500

Hiroyuki,

You can evaluate the range of the variables in your graph within the
do-file to identify appropriate labels.

. sysuse auto
. sum weight, meanonly
. local xmin = floor(r(min) / 500) * 500
. local xmax = ceil(r(max) / 500) * 500
. sum mpg, meanonly
. local ymin = floor(r(min) / 5) * 5
. local ymax = ceil(r(max) / 5) * 5
. scatter mpg weight, xscale(r(`xmin' `xmax'))
xlabel(`xmin'(500)`xmax') yscale(r(`ymin' `ymax'))
ylabel(`ymin'(5)`ymax')

I selected the values 5 and 500 after visual inspection of the data.
You can also write code that specifies appropriate steps for the axis
labels based on the difference between the maximum and minimum values
of a variable. The values in the example above would then be replaced
by two additional macros, e.g. `xstep' instead of 500 and `ystep'
instead of 5.

Friedrich

On Fri, Feb 13, 2009 at 8:46 AM, Hiroyuki Kawakatsu <[email protected]> wrote:
>> Scott Merryman wrote:
>>
>> twoway line x x,  xlabel(1(1)10) ylabel(1(1)10)  graphregion(margin(zero ))
>>
>> or
>>
>> twoway line x x, xlabel(1(1)10) ylabel(1(1)10) plotr(m(zero))
>> graphregion(margin(zero ))
>
> Thanks Scott. It is unfortunate that the solution requires knowledge
> of the range of data values that x can take. It would be nice if we
> can retain the default label positions in the interior of the axis.
>
> h.
> --
> +---
> | Hiroyuki Kawakatsu
> | Business School, Dublin City University
> | Dublin 9, Ireland. Tel +353 (0)1 700 7496
*
*   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/



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