Announcement

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

  • Consolidating two line graphs and editing X and Y axis labels and title on Line Graph

    Hi, I am working with a dataset of 14 observations, and I am trying to make a line graph using these observations. I would like to make two lines on one graph; however, right now I just have two line graphs. I would like to have one line that is for the observations that match the criteria fpuc2_refusal==0 and another line that is for the observations that match the criteria fpuc2_refusal==1. There should be 7 observations in each category.

    Here is the code I am using right now:
    line unemployment_rate_groups date if fpuc2_refusal==0,
    xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul"),
    xtitle("Month of 2021"),
    ytitle("Unemployment Rate"),
    title("Monthly Unemployment Rate for States that Kept FPUC"),
    note("Source: Current Population Survey")

    line unemployment_rate_groups date if fpuc2_refusal==1,
    xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul"),
    xtitle("Month of 2021"),
    ytitle("Unemployment Rate"),
    title("Monthly Unemployment Rate for States that Refused FPUC"),
    note("Source: Current Population Survey")

    The code runs and makes a line graph, but it says "command xlabel is unrecognized" and so anything from xlabel to the note does not get implemented into the line graphs.
    Is there a way to get both of these lines on the same graph and also edit the x and y axis labels so that the graph looks nicer?

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float date byte fpuc2_refusal double(emp1 emp2 emp3) float unemployment_rate_groups
    732 0 22584 1738  9431  7.145794
    733 0 23066 1684  9410   6.80404
    734 0 22633 1569  9122  6.482935
    735 0 23390 1508  9580  6.056711
    736 0 23307 1413  9484   5.71602
    737 0 22456 1525  8856  6.359201
    738 0 22689 1503  8576  6.212798
    732 1 24144 1400 10250  5.480739
    733 1 23380 1372  9788  5.542986
    734 1 22958 1201  9693  4.971232
    735 1 23927 1177  9945 4.6884956
    736 1 23709 1135  9670 4.5685077
    737 1 22791 1205  9049   5.02167
    738 1 23185 1067  8967  4.399637
    end
    format %tm date

  • #2
    line break is ///
    Code:
    line unemployment_rate_groups date if fpuc2_refusal==0, ///
    xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul") ///
    xtitle("Month of 2021") ///
    ytitle("Unemployment Rate") ///
    title("Monthly Unemployment Rate for States that Kept FPUC") ///
    note("Source: Current Population Survey")

    Comment


    • #3
      I tried inputting that code into the command section, but I got these errors:

      line unemployment_rate_groups date if fpuc2_refusal==0,

      xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul")
      command xlabel is unrecognized
      r(199);

      xtitle("Month of 2021")
      command xtitle is unrecognized
      r(199);

      ytitle("Unemployment Rate")
      command ytitle is unrecognized
      r(199);

      title("Monthly Unemployment Rate for States that Kept FPUC")
      command title is unrecognized
      r(199);

      note("Source: Current Population Survey")
      type mismatch
      r(109);

      Comment


      • #4
        All one command to be entered as one line if you are using the Command window.

        Comment

        Working...
        X