Announcement

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

  • Comparing several histograms

    Hi All!

    I'm trying to make a figure like the one below, that allows me to (1) change color from histogram to histogram and (2) put a few of the labels on the left-hand side under headings. I've been trying to do it with "onewayplot" but I'm not sure I can change the color for each and doesn't allow the "headings" option.

    Thanks for any suggestions! Here's some sample code that I've been playing with:
    sysuse auto, clear
    onewayplot price, by(foreign) stack ms(oh) msize(small) width(1000) color(red) height(.4)

    Click image for larger version

Name:	many histograms.PNG
Views:	1
Size:	23.7 KB
ID:	1473390
    0
    It's not possible, dummy: move on
    0%
    0
    It's possible, but I don't know how
    0%
    0
    You can do this, but it's a little work
    0%
    0
    No problem, buddy: sit down, it's super easy
    0%
    0

  • #2
    I guess that you've been looking at https://www.stata-journal.com/sjpdf....iclenum=gr0003 which was published in 2004. onewayplot (from SSC, as you are asked to explain) discussed there and used for your example has morphed into stripplot (also SSC) and is no longer maintained, as is documented in njc_stuff (also SSC).

    Sorry, but I have no idea what you mean by 2). On 1) different colours are possible with stripplot for different groups. Here's one example: Naturally you can mess around with different colours if so minded.

    Code:
    webuse nlswork, clear
    stripplot ln_wage, ms(p p p)  width(0.025) height(0.9) stack over(race) separate(race) legend(off)
    Click image for larger version

Name:	coloured_stripplots.png
Views:	1
Size:	61.4 KB
ID:	1473472


    Half deliberately, this shows a possible limitation of stripplot, depending on your goals. The principle is simple: each data point is represented by a graphical point, a marker. That makes it ill-suited for comparing groups of very different sizes. Many other designs are naturally available.

    Comment


    • #3
      Dear Nick,

      Terrific; thanks so much for your help. I can just set the colors using the option mcolor(blue red purple).

      I didn't explain the "heading" question very well: Here's an example, below, where there are headings like "Asylum testimony" and "Gender". In my setting, there are 20 rows that fall under different categories that would be nice to separate.

      For me, the fact that the group sizes are different isn't a big issue because I'm showing the results of simulations of equal number.

      This is very helpful, thank you!
      Click image for larger version

Name:	headings.PNG
Views:	1
Size:	85.7 KB
ID:	1473546

      Last edited by Andrew Jensen; 05 Dec 2018, 10:49.

      Comment


      • #4
        I think I understand better what you mean by headings, but I am still not clear what you want overall. You've so far presented two different displays and none of your own data. #3 is in no sense a histogram or collection of histograms.

        These papers may help:

        https://www.stata-journal.com/sjpdf....iclenum=gr0034

        https://www.stata-journal.com/sjpdf....iclenum=gr0061

        Comment

        Working...
        X