Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: change values in the x-axis


From   Nick Winter <nwinter@virginia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: change values in the x-axis
Date   Mon, 19 Sep 2011 11:12:02 -0400

I don't think there is a way to get Stata to "lie" about the numbers on the axis, other than to manually list the labels you want for each point. But you can probably automate the process of generating those labels. For example:

*****************
sysuse auto, clear

gen w = (weight-1700)*6
gen nw=-w

forvalues i=-20000(1000)20000 {
  local lab : di %10.0fc abs(`i')
  local xlabs `"`xlabs' `i' "`lab'""'
}

di `"label string: [`xlabs']"'

graph twoway histogram w || ///
  histogram nw , ///
  xlab(`xlabs', labsize(vsmall) angle(vert))

******************


Nick Winter

On 9/19/2011 9:45 AM, Emmanouil Mentzakis wrote:
Hello,

I am doing a bar graph and my x-axis takes values from -20000 to
20000. Is there a way to hide the negative signs of the values left of
the zero. e.g.

clear all
sysuse auto
gen price2=-price
gen n=_n
twoway (bar price n, horizontal) (bar price2 n,  horizontal)


In the above graph i d like the values of the x-axis to be (left to
right): 20000 10000 0 10000 20000. Unfortunately I have quite a few
values and manually defining new label for my price2 would be hard.

Any suggestions would be much appreciated.

Regards
Manos
*
*   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/

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Associate Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
S385 Gibson Hall, South Lawn
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index