Announcement

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

  • Scatter plot for one variable

    Hey guys,

    I have a question concerning graphs in Stata and I hope you can help me. I want to illustrate the observations for one single variable in one graph. This variable contains about 150 values betwen -1 and +1. I would like to illustrate all of them as a scatter plot. However, scatter plots require two variables and I just want to illustrate all values of one variable. I have searched for solutions but could not find any satisfying answer. Does Stata provide any solution for this?

    Best regards,
    Tobias
    Last edited by Tobias Simon; 21 Jun 2017, 10:15.

  • #2
    Code:
    help histogram
    help spikeplot
    help dotplot 
    search qplot 
    search stripplot

    Comment


    • #3
      You can simply generate a dummy variable containing the observation number and then use it as you x-var.
      Code:
      gen x=_n
      graph twoway scatter y x
      Here y is your variable containing the values of interest.

      Comment


      • #4
        Originally posted by M. Cleves View Post
        You can simply generate a dummy variable containing the observation number and then use it as you x-var.
        Code:
        gen x=_n
        graph twoway scatter y x
        Here y is your variable containing the values of interest.
        Sir, can I use this method while also using 'lfit' option which lets me fit a linear line to the scatter plot?

        Comment

        Working...
        X