I want to create a histogram with data on wage, and have the xaxis a log axis. Can I have the bins of the histogram equal log width so that they look like they have the same width on the graph? I have already generated the log wage variable from the wage variable. If I use the log wage variable, the xaxis will display as a log variable, but I think it will look better to have the actual wage displayed on the axis. Alternatively, I can achieve the same purpose by using the log wage variable but then somehow displaying the xaxis as the actual wage. Can you help?
Announcement
Collapse
No announcement yet.
X

I've often wanted this but always worked ad hoc. The only method I know is do everything on log scale but let the axis labels show the original scale. It's hard to do this cleanly unless your bin limits are integer powers of 10 (or 2, arguably), so far as I can see.
Some technique:
Code:clear set obs 1000 set seed 2803 gen y = exp(rnormal(7, 2.5)) su y label var y "Whatever" gen logy = log10(y) su logy * prior ssc inst mylabels required for this to work mylabels 1 10 100 1000 1e4 1e5 1e6, myscale(log10(@)) local(xla) histogram logy, width(1) start(1) xtitle("`: var label y'") xla(`xla') /// bfcolor(ltblue) blcolor(ltblue*2)
Last edited by Nick Cox; 14 Sep 2017, 06:33.
 1 like

I managed to do it by adding individual ticks and labels in the graph editor (using a calculator to find what ln(10), ln(100), ln(1000) etc are):
I know I'm going to ask another question now, so tell me if I need to start a new topic. How can I get a line showing the mean or median of each distribution?
Comment
Comment