Announcement

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

  • Graph: How to omit one particular label in the legend

    Hello all,

    I face a little problem regarding the following Graph:

    gr tw (scatter unemployed_educ_ter_perc labour_force_ter if sample_selection == 1, legend(label(1 Low & Lower-Middle Income))) ///
    (scatter unemployed_educ_ter_perc labour_force_ter if sample_selection == 2) ///
    (function y=x, range(0 60)), title("Share of Labour Force vs. Unemployment ""(Tertiary Education), lates year available (%)", size(medium)) ///
    note("Source: International Labour Organization internal database, available upon request.", size(vsmall) ring(5) position(5)) ///
    legend(label(1 Low & Lower-Middle Income) label(2 High Income) size(small) region( lcolor (white))) xtitle("Share of labour force with tertiary level of education", size(small)) ///
    ytitle("Share of unemployed with tertiary level of education", size(small)) xlabel(0(10)60, labsize(small)) ylabel(0(10)60, labsize(small)) graphregion(color(white)) bgcolor(white) play (**MY_RECORDING**)


    The y=x line is a reference line. I would like to omit the line, therefore, it from the legend. However, I have not found a good solution.

    neither label(3 "") nor omitting the label does resolve my issue. Any thoughts and comments are highly appreciated!


    Solution/Update: I have now set
    region(lcolor(white)) for the legend

    then: I hide the object in the manual graph editor and add the play command in the graph. Still, any more sophisticated solution is highly welcome!
    Best

    Justus
    Last edited by Justus F.C. Meyer; 25 May 2017, 03:33.

  • #2
    Use the legend(order ()) option:

    Code:
     set obs 100
     gen x = runiform()
     gen x2 = runiform()
     gen y= runiform()
     scatter y x2 x || function  y = x || , legend(order(1 "Variable 1" 2 "Variable 2"))

    Comment


    • #3
      That worked perfectly! Thank you very much. I think both are solutions, but your's is of course much more elegant. I hope this might also help some people who encounter the same problem.

      Comment


      • #4
        Three and a half years later, another upvote for this solution. Thanks!

        Comment

        Working...
        X