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]

st: change range of axis in bar graph (start counting from 1, not from 0)


From   Hilde Karlsen <[email protected]>
To   [email protected]
Subject   st: change range of axis in bar graph (start counting from 1, not from 0)
Date   Mon, 4 Jul 2011 11:51:25 +0200

Dear statalist

I cannot gain control over the "x-axis" in my bar chart. I have read
the manual on -graph bar-, and I see that there really is no 'x-axis'
in bar charts, so I figure that what I am trying to do is to change
the range of the y-axis.

My syntax looks like this:

graph hbar (mean) Social if schools <=3, over(gender) over(education) ///
blabel(bar,format(%9.2f)) ///
ytitle(Mean) ///
title(Kompetence gained: Social) ///
scheme(s1mono)

This syntax results in horisontal bars over gender over education with
an axis which ranges from 0 to 4. However, this does not mach how the
dependent variable is defined in the data, i.e. ranging from 1 to 5.
What I would like is to have the axis beginning to count at 1 and
ending at 5.

I have read this page <
http://www.stata-journal.com/sjpdf.html?articlenum=gr0019 > and it
seems to do exactly what I want; however, the example given is for a
twoway diagram, for which we can speak of an x-axis as well as a
y-axis. In this number of the Stata Journal, Nicholas J.G. Winter
writes that:

"The issue is that the range displayed for an axis depends on the
interaction between two sets of options (or their defaults): those
that control the axis range explicitly, and those that label the axis.
The range can be expanded either by explicitly specifying a longer
axis (e.g., with xscale(range(a b))) or by labeling values outside the
range of the data."

Then he goes on to offer some solutions which I have tried but which
does not work on the bar chart,  i.e. I have the range expanded to
include "5", but I cannot have the axis begin counting from 1; it
insists on counting from 0, which means that expanding the range to
include 5 in fact produces an axis with 6 values.

I have also tried to use the graph editor to fix this; however, it
seems the graph editor does not allow one to choose a minimum value
higher than zero. (?)

Any help on this matter will be highly appreaciated.

Best regards,
Hilde
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index