Announcement

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

  • How can I adjust the x-axis display range of my histogram

    Good morning, all. I'm new to stata

    I want to graphically represent a variable 25,840 observations, ranging -7.5 - 7.5. However, the histogram plot keeps starting from -10 to +10. I have consulted multiple online resources, and I've tried out the following code:

    histogram zfacility_index, width(0.34) percent normal ytitle(Proportion of facilities) xtitle(Composite Index Score) xscale(range(-7.5 7.5)) title(Alt B composite score distribution)
    Click image for larger version

Name:	statalistenquiry.png
Views:	1
Size:	61.1 KB
ID:	1718782


    Moreso, despite changing my y-axis option to percentage, I keep getting a scale value (0 to 4) instead of percentage values.

    How can I change these? Thanks

  • #2
    You need to spell out through xlabel()whatever labels you prefer if you don't like the default, say an extra option

    Code:
    xla(-7.5(2.5)7.5)
    The option percent is doing exactly what you ask as you have about 40 bins, so on average bar height should be about 100/40 = 2.5, which fits what you show. But then the title Proportion of facilities is -- according to taste either inappropriate or just wrong -- as proportions are in the range 0 to 1. Where does the width of 0.34 come from? You can have whatever width you like but the percents shown will vary correspondingly.

    A normal distribution doesn't seem a natural reference here. Your score is bounded and the limits are attained in the data, or nearly so, so a normal can't be anything but a poor fit. It distracts attention from the data, including some apparent bimodality.

    I would add that quantile plots cut out all faff around choice of bin origin or bin width and what each bar shows precisely!
    Last edited by Nick Cox; 29 Jun 2023, 05:08.

    Comment

    Working...
    X