Announcement

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

  • Changing x axis range on line plot

    Hey guys, this might be a really silly question. I'm trying to plot density plots of two groups (see attached). The x axis automatically goes from -400 to 400, but when I set the xlabel from -200 to 400, it still shows the portion of the graph that's less than -200 and the axis looks weird. How do I configure this graph so the x-axis truly starts at -200?


    Code:
    line fx0 fx1 x, sort ytitle(Density) xlabel(-200 400)
    Attached Files

  • #2
    This is a common mistake. As the Stata documentation explains, all that -xlabel()- does is tell Stata which points on the axis to label, and what to label them with. It has no role at all in determining the span of the axis. The span of the axis is always determined by the range of the x variable. So to change that, you have to change the range of the data.

    Code:
    line fx0 fx1 x if x > -200, sort ytitle(Density) xlabel(-200 400)

    Comment


    • #3
      Thank you!!

      Comment

      Working...
      X