Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to reproduce a histogram produced by a spreadsheet program?

    I am attempting to redraw a histogram produced using MS Excel. I have the data that describes the bins that were used and the frequencies within each bin, and I have those data in Stata. What I can't figure out is the tricks to reproduce the original chart. With pcspike, I can draw the (short horizontal) line at the required height for each bin, but haven't managed to shade the area beneath that line. I was hoping that some deft use ofa recast() option would help me, but the area plottypes are not available if you use the pc* suite. Here follows the original histogram, the data in Stata format, and what I've managed so far. (The stripe effect and other decorations are not essential aspects right now; I think I can figure those out once I've got my first question sorted.)




    Click image for larger version

Name:	hbai-hist.png
Views:	1
Size:	15.1 KB
ID:	318513



    Code:
    . list, noobs clean
    
        incbin   incbina      freq1      freq2 
             0        10    .557966          . 
            10        20    .017816          . 
            20        30     .05715          . 
            30        40    .080428          . 
            40        50    .047923          . 
            50        60    .055643          . 
            60        70    .090127          . 
            70        80    .137397          . 
            80        90    .105367          . 
            90       100    .094861          . 
           100       110    .154123          . 
           110       120    .165358          . 
           120       130    .258034          . 
           130       140    .207471          . 
           140       150     .24264          . 
           150       160    .243674          . 
           160       170    .345994          . 
           170       180    .377289          . 
           180       190    .552492          . 
           190       200    .549161          . 
           200       210    .649822          . 
           210       220    .768927          . 
           220       230    .773384          . 
           230       240          .    .893827 
           240       250          .    .913016 
           250       260          .     .91981 
           260       270          .   1.151037 
           270       280          .   1.182238 
           280       290          .    1.33704 
           290       300   1.382079          . 
           300       310   1.341233          . 
           310       320     1.2676          . 
           320       330   1.276795          . 
           330       340   1.245946          . 
           340       350          .   1.346329 
           350       360          .    1.38345 
           360       370          .   1.209365 
           370       380          .   1.173525 
           380       390   1.157792          . 
           390       400   1.232989          . 
           400       410   1.304124          . 
           410       420   1.063262          . 
           420       430    1.12376          . 
           430       440   1.018589          . 
           440       450          .   1.036369 
           450       460          .   1.087997 
           460       470          .   1.170858 
           470       480          .    .883694 
           480       490          .    .981654 
           490       500          .   1.039451 
           500       510    .896215          . 
           510       520    .931112          . 
           520       530    .898932          . 
           530       540    .726286          . 
           540       550    .799756          . 
           550       560    .685389          . 
           560       570    .812481          . 
           570       580    .758586          . 
           580       590          .    .589386 
           590       600          .    .754324 
           600       610          .    .683959 
           610       620          .    .612078 
           620       630          .    .623528 
           630       640          .    .584397 
           640       650          .     .53353 
           650       660          .    .480557 
           660       670          .    .561119 
           670       680          .    .475644 
           680       690    .446218          . 
           690       700    .419029          . 
           700       710    .416947          . 
           710       720    .417905          . 
           720       730    .431799          . 
           730       740     .37112          . 
           740       750    .444064          . 
           750       760    .352618          . 
           760       770    .362807          . 
           770       780    .372367          . 
           780       790    .278512          . 
           790       800    .314031          . 
           800       810    .262583          . 
           810       820    .201899          . 
           820       830    .224832          . 
           830       840    .222738          . 
           840       850    .229088          . 
           850       860    .280165          . 
           860       870    .229097          . 
           870       880    .201099          . 
           880       890          .    .173056 
           890       900          .    .179613 
           900       910          .    .233696 
           910       920          .    .183364 
           920       930          .    .200443 
           930       940          .    .170313 
           940       950          .    .152524 
           950       960          .    .152015 
           960       970          .    .154548 
           970       980          .    .150242 
           980       990          .    .146544 
           990      1000          .    .161097 
          1000      1010          .          . 
    
    . tw (pcspike freq1 incbin freq1 incbina )(pcspike freq2 incbin freq2 incbina )
    
    . tw (pcspike freq1 incbin freq1 incbina, recast(area) )(pcspike freq2 incbin freq2 incbina, recast(area) )
    (note:  named style area not found in class yxyxtype, default attributes used)
    (note:  yxyxtype not found in scheme, default attributes used)
    (note:  named style area not found in class yxyxtype, default attributes used)
    (note:  yxyxtype not found in scheme, default attributes used)

  • #2
    Code:
     
    gen incbing = (incbin + incbina)/2
    twoway bar freq1 incbing, barw(10) || bar freq2 incbing, barw(10)
    seems the highest hurdle to jump.

    .

    Comment


    • #3
      Aha! Simpler than I had thought. Many thanks! First hurdle now leapt over ...

      Comment

      Working...
      X