Bookmark and Share

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

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

RE: st: How to draw axes in the interior of the plot?

From   Nick Cox <>
To   "''" <>
Subject   RE: st: How to draw axes in the interior of the plot?
Date   Mon, 20 Sep 2010 12:05:57 +0100

I disagree partially with Roger. 

The problem is clearly not with drawing axis lines wherever one wants, for which in this case -xli()- and -yli()- are to hand. The problem is that axis labels and ticks are associated with axis lines. I think Stata made a decision in principle way back that labels and ticks belong on the margins of a graph so that they _never_ interfere with data and I very much doubt that that is regarded as a problem to fix. 

Be that as it may, the StataCorp position is presumably that you can emulate axis labels and ticks yourself, as shown for example by Scott, so that is what they would recommend for those determined to go ahead with axes cutting through the graph region. 


Roger Newson

Thanks to Scott for this solution, which I have forwarded to my colleague.

It seems a bit surprising that Stata does not seem to be able routinely 
to locate axes in the interior of a graph region, instead of at the 
boundary of a graph region. After all, lots of people might want to plot 
the complex plane with axes intersecting at (0,0i). However, StataCorp 
may decide to fix this, when they have time to spare from the 
innumerable other things they do for us. I might raise it at the Wishes 
and Grumbles session of the 2011 UK Stata User Meeting, if they haven't 
fixed it by then.

Scott Merryman

> You can use yline() and xline() to recreate the axes and use
> -scatteri- for the tick marks and labels.
> For example (using Ben Jann's -center-):
> sysuse auto, clear	
> center mpg price
> scatter c_p c_m ,yscale(off) xscale(off) legend(off) ylabel(,nogrid)
> graphregion(color(white))  ///
>    || scatteri 0 -10 "-10" 0 10 "10" 0 20 "20", mlabpos(6) ms(none)
> mlabcolor(black) ///
>    || scatteri 0 -10 "|" 0 10 "|" 0 20 "|" , mlabpos(0) msy(none)
> mlabcolor(black) ///
>    || scatteri -5000 0 "-5000" 5000 0 "5000" 10000 0 "10000",
> mlabpos(9) ms(none) mlabcolor(black) ///
>    || scatteri -5000 0 "`=char(151)'"  5000  0 "`=char(151)'" 10000 0
> "`=char(151)'",  mlabpos(0) ms(none) mlabcolor(black) ///
>     yline(0, lc(black)) xline(0, lc(black))

Roger Newson

>> I suspect that I am being very stupid today, and missing something that
>> should be obvious. I have a colleague who wants to draw axes in the interior
>> of the plot region in a Stata graph (as most people do when displaying the
>> complex or Argand plane with 0+0*i at the centre), complete with tick marks
>> and labels on whatever side the user chooses. However, I have been looking
>> through the Stata Version 11 .pdf manuals and the Stata Version 10 hardcopy
>> manuals, and I cannot find any reference to this possibility, although there
>> is a lot about putting axes on the left, right, top or bottom of the graph
>> region, and the possibility of up to 9 axes (presumably to allow outside and
>> inside labelled ticks at the left, right, top and bottom).
>> Is there a way to do this in Stata graphics? I have checked all the axis
>> options and the added_line_options, but can't seem to find a way.

*   For searches and help try:

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