Announcement

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

  • Line graph

    Hi,

    I am trying to make a simple graph of union membership rate over the 3 years 2001, 2009 and 2023. As I have repeated cross sectional data, I have not merged my datasets. Instead I have created a new file and inputted the membership rates manually as the code below shows:
    *
    input year union_membership
    2001 30.4%
    2009 28.7%
    2023 26.3%
    end

    line union_membership year, title("Union Membership Rate")
    ytitle("Unionization Rate (%)") xtitle("Year")
    xticks("2001 2009 2023") xticklabel("2001" "2009" "2023")

    *

    When graphing this, it seems to give me all the years from 2000 to 2025, but I want distinctly 3 points at 2001, 2009 and 2023. Does anyone know how to do this? I have attached an image of the graph below.

  • #2
    Unfortunately, STATAlist doesn't allow me to upload a file. However, the x axis ranges from 2000 to 2025, whereas I am trying to have just 3 points at 2001, 2009, and 2023.

    Thank you

    Comment


    • #3
      No need to indicate anything else except the unit of measurement in the y-title, as you already have a title. It is also obvious that the x-axis represents years. However, the option you are looking for is -xlabel()-. Of course, you can use all the data and indicate only these three years on the axis. Currently, you are discarding some variation, and some may consider this distortion.

      Code:
      clear
      input float(year union_membership)
      2001 30.4
      2009 28.7
      2023 26.3
      end
      
      line union_membership year, title("Union Membership Rate") ///
      ytitle("Percent") xtitle("") xlab("2001 2009 2023")
      xticks("2001 2009 2023") xticklabel("2001" "2009" "2023")
      Res.:

      Click image for larger version

Name:	Graph.png
Views:	1
Size:	42.8 KB
ID:	1749331




      Comment


      • #4
        Thanks for the help, Andrew! My dataset consists of repeated cross-sections only for 2001, 2009 and 2023, and thus I do not have data pooled on the other years to be able to construct such a graph.

        Comment


        • #5
          I misread #1, sorry.

          Comment

          Working...
          X