Announcement

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

  • Restricting y-axis with fpfit

    Dear Statalisters,

    I've encountered a problem where I'm trying to restrict the y axis scale to show particular range that I want. For example, I would like to restrict y-axis to be in between 15 and 20. Here is a sample of my code:

    Code:
    sysuse auto
    twoway (scatter mpg price if mpg >15 & mpg < 20) (fpfit mpg price)
    However, using fpfit will extend the y axis to show the curve that fits the scatter plots. I do not want to see anything above mpg greater than 20. How can I do that? I try using if statement, but I know that using if statement on fpfit will distort the fit.

    Using yscale(range(15 20)) did not help either. Any suggestion?
Working...
X