Announcement

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

  • Not all x-axis labels shown in a histogram by group

    Dear Stata users,

    Can anyone help me with the following: I have made a histogram per group (age group and gender). My issue is that the x-axis labels are only shown in the bottom, but I would like to have them for all graphs separately. See the added picture.
    I added below a sample of the data and my code.


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float agegroup byte ragender float r75liv
    2 1   .2
    2 1    1
    3 1   .1
    2 1   .5
    2 2   .8
    1 2   .8
    1 2   .5
    3 1   .8
    2 1   .8
    2 2    1
    2 2   .9
    3 2  .85
    3 2   .8
    1 2   .8
    3 1   .3
    3 1   .5
    3 2   .8
    1 1    1
    1 2   .5
    2 2   .5
    2 2   .5
    1 2   .4
    2 2   .1
    1 2   .7
    3 2    1
    3 1   .1
    2 2   .8
    1 1    1
    1 2   .9
    1 1   .4
    3 2  .05
    2 2   .4
    2 1  .75
    1 1   .5
    3 1   .6
    3 2   .6
    3 2   .7
    3 2    1
    3 2  .75
    1 2   .9
    1 1    1
    3 2   .5
    1 2   .5
    3 2   .5
    1 1   .7
    3 1   .7
    2 1  .75
    3 1   .7
    3 2   .3
    2 2   .1
    1 2   .6
    2 1   .9
    2 2   .9
    3 1  .75
    2 1   .5
    3 1   .5
    1 1   .4
    3 2   .4
    2 2   .9
    3 2  .75
    2 2   .9
    3 2   .8
    3 2  .75
    1 2   .9
    3 2   .9
    3 2   .5
    1 2   .5
    3 2   .5
    1 1    1
    2 1   .7
    3 1   .9
    3 1   .9
    3 2   .9
    2 2    1
    2 2    1
    2 2    1
    3 2    1
    2 2   .5
    2 1   .9
    2 2    1
    2 1   .4
    2 1   .1
    1 1   .2
    3 1   .2
    3 1   .1
    3 2   .4
    3 2  .75
    2 2   .9
    1 2   .5
    3 2 -.25
    3 2 -.25
    1 2   .5
    3 2   .8
    3 2   .8
    2 2    1
    1 2   .5
    2 2   .7
    3 1   .8
    2 2   .5
    1 2   .8
    end
    label values agegroup agegroups
    label def agegroups 1 "50-53", modify
    label def agegroups 2 "54-57", modify
    label def agegroups 3 "58-61", modify
    label values ragender genderl
    label def genderl 1 "Male", modify
    label def genderl 2 "Female", modify

    Code:
    /* Graph showing focal points, per gender and age-group  */
    histogram r75liv, by(ragender agegroup) bin(100) fcolor(midblue%86) lcolor(midblue) xlabel(-0.25 "D/R" 0 "0" 0.50 "0.5" 0.80 "0.8" 1 "1")
     //saving(focalpoints.gph, replace)

    Thank you in advance.
    Attached Files

  • #2
    Perhaps you want to use the following":
    Code:
    histogram r75liv, by(ragender agegroup , ixaxes ) bin(100) fcolor(midblue%86) lcolor(midblue) xlabel(-0.25 "D/R" 0 "0" 0.50 "0.5" 0.80 "0.8" 1 "1")

    Comment


    • #3
      Thank you very much, that solves the issue!

      Comment

      Working...
      X