[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Histogram with options
> I can never seem to get the histogram syntax quite right - have
> for ages with the syntax. I would like to have the following
features in the
> 1. The variable has 8 categories, and I would like each category to
> bin. (Even when I include -bin(8)- in the syntax I get fewer bins
Presumably your variable consists of equally spaced values, such
as consecutive integers.
Some of the bins may be empty in some cases. Otherwise I cannot
diagnose this from the evidence supplied. I would need to
see data and what you typed.
> 2. Each bin should be labelled. (I have made value labels, but only
> for the bins at the extreme left and right appear, not the ones in
With say values 1(1)8, you could go
... xla(1/8) xsc(0.5,8.5)
or check out -hist-.
> 3. The x axis should preferably not have any ticks.
When you say "ticks", I guess you mean "unlabelled ticks".
Usually achieved by something like the above.
> 4. The height of each bin shows the relative proportion of votes
> received in a recent election (New Zealand). I guess this means I
> include the "freq" option in the syntax?
I don't know what you mean by "relative proportion" here. Is this
what you want or what you get?
> 5. The y axis should range from 0 to 50, with ticks at 0, 10, 20,
30, 40, 50.
When you say "ticks", I guess you mean labels.
.... ysc(0,50) yla(0(10)50)
But in general, this does not sound like a variable which
should be plotted as a histogram, as you have categories
which are not on a continuous scale.
You perhaps need a bar chart. Check out (e.g.) -fbar- from SSC.
In general, your value labels will be truncated at eight characters
whenever you use any graph command based on -graph-.
-graph, histogram- is one and -hist- and -fbar- are others.
This is only soluble in Stata by using graph commands
based directly on -gph- such as -hplot- or -hbar-.
For locations of non-official programs, use -findit-.
* For searches and help try: