Announcement

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

  • Saving table behind histogram

    I am using a histogram, and I want to save a table underlying the graph.

    for instance:

    sysuse auto
    hist weight
    I want to then have the table behind this chart. The reason is that I want to graph the portion only of this histogram (say for bins above 3,000) on a separate graph that combines other components as well.

    hist weight if weight>3000
    does not do what I want, because that produces density for values over 3,000. I want to have density for all values, but then plot only a truncated density. How can this be done? If I had the table from the original histogram, I could then graph subset from that.

    I thought serset would do it, but that produces empty data.

  • #2
    SJ-5-2 gr0014 . . . . . . . Stata tip 20: Generating histogram bin variables
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . D. A. Harrison
    Q2/05 SJ 5(2):280--281 (no commands)
    tip illustrating the use of twoway__histogram_gen for
    creation of complex histograms and other graphs or tables

    https://www.stata-journal.com/articl...article=gr0014

    Example code:

    Code:
    sysuse auto, clear
    hist weight, start(0) width(500)
    twoway__histogram_gen weight, width(500) start(0) gen(y x)
    list y x if !missing(y, x)
    set scheme s1color
    twoway bar y x if x > 3000, barw(500) bfcolor(none)

    Comment


    • #3
      https://journals.sagepub.com/doi/pdf...867X0500500213
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Thank you! That's exactly what I was looking for.

        Comment

        Working...
        X