Announcement

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

  • Changing color of single line in Stata figure

    I'm trying to change the color of just one line in my figure, featuring 4 lines. I'm fine with the default gray scale settings for all other lines, but for one line, I'd like to show it in color. What do I insert in the following snippet of code. Many thanks...

    Code:
     line sm5_ex3_rec1 sm5_ex3_rec2 sm5_ex3_rec3 sm5_ex3_all year_month,
          xtitle("Base month") ytitle("Monthly job-finding rate")
          ylabel(0.1(.05).4)
          xlabel(708(12)743, format(%tmCCYY) notick) xtick(708(3)749, add)
          legend(cols(2)rows(2))
          title("Monthly job-finding rates for all unemployed workers," "by pre-pandemic recipiency")
          note("Notes: Data are not seasonally adjusted, and are smoothed using a 5-month symmetric" "triangle moving average.")
          saving(fig9, replace);

  • #2
    Some variation on

    Code:
    lc(black black black red)
    where the colo[u]rs and order are naturally your choice within the constraint of four colo[u]rs for four y-axis variables.

    See also https://www.stata-journal.com/articl...article=gr0030 on labelling years and months for monthly data. (The paper uses quarters as an example, but the idea is the same.)

    Searching the forum for mentions of gr0030 is also a possibility.

    Comment


    • #3
      Perfect; thank you

      Comment


      • #4
        Here's a recipe for 3 years' worth of monthly data.

        Code:
        clear 
        set obs 36
        range mdate 708 743 
        
        gen y = runiform() 
        
        line y mdate, xtick(707.5(12)743.5, tlength(*3)) ///
        xla(713.5(12)737.5, tlc(none) format(%tmCCYY)) xtitle("") xmti(708/744, tlength(*2))
        Click image for larger version

Name:	mdate.png
Views:	1
Size:	46.5 KB
ID:	1692032

        Comment


        • #5
          Thank you! I like the x-axis labels better here (I'm showing 3.5 years of data)

          Comment

          Working...
          X