Search code examples
plothistogramstata

"Histogram-like" graph


I have a dataset made as follows:

norm_year   annualsaleswwsales
0   567.9555
1   799.0374
2   940.2049
3   1078.865
4   1242.016
5   1414.186
6   1515.54
7   1641.781
8   1637.157
9   1690.494
10  1616.352
11  1134.324
12  1056.123
13  919.7526
14  642.4491

I would like to do a histogram-like plot in Stata where on the y-axis I have annual sales instead of frequency and on the x-axis the normalized year. Ideally, the bins should be transparent and a line should connect each pick of the histogram.

How can I do so?


Solution

  • A connecting line seems to me over the top in more ways than one, but here is some technique.

    clear 
    input norm_year   annualsaleswwsales
    0   567.9555
    1   799.0374
    2   940.2049
    3   1078.865
    4   1242.016
    5   1414.186
    6   1515.54
    7   1641.781
    8   1637.157
    9   1690.494
    10  1616.352
    11  1134.324
    12  1056.123
    13  919.7526
    14  642.4491
    end 
    
    twoway bar annualsaleswwsales norm_year, fc(none) xla(0/14) base(0) yla(0(200)1600)
    

    enter image description here