Announcement

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

  • restricting x-axis with distplot

    Hello statalisters

    I am ploting the empirical cdf of my data using distplot. I would like to truncate the plot, since the data are distributed with a long right tail and I'm not interested in that part of the distribution. I've tried doing this with the following command:

    Code:
    distplot hh_land if year == 2014 , xlabel(0(2)46) xscale(range(0 46) noextend)


    However this only restricts the ticks on the axis, and not the length of the axis, or the range of values, for which the empirical cdf is plotted, which clearly still range over (0, 150) . What have I done wrong?

    Thanks

  • #2
    distplot is from the Stata Journal as you are asked to explain (FAQ Advice #12).

    This won't work as you wish. Stata will never omit data from a graph in response to an axis scale option. This is explicitly documented (see the help for axis scale options):

    range() never narrows the scale of an axis or causes data to be omitted from the plot.
    Conversely if you specify if with distplot the calculations will be wrong.

    It's perhaps noting that I as author of distplot have consciously not provided a work-around for this kind of desire.

    Your only hope to get exactly what you ask is create the cumulative distribution functions yourself e.g. with cumul and then plot the parts that interest you.

    Another suggestion: whenever this happens the difficulty often underlines that the researcher would be better off thinking on logarithmic or (if zeros are present) some other transformed scale.

    Comment


    • #3
      Ok, thanks very much for the detailed explanation, that certainly adresses everything.

      My apologies for not checking the FAQ and the documentation closely enough, thanks for bearing with me.

      Comment

      Working...
      X