Announcement

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

  • adding label in spmap

    Hello,

    My query is very simple, I would like to add label of a categorical variable in spmap

    I am using STATA 15. The variable rc_norm_4_Cat has 4 categories already defined.

    gen byte rc_norm_4_Cat=recode(rc_norm_4,1,2,3,4,.)


    colorpalette w3 blue, n(4) nograph
    local colors `r(p)'
    spmap rc_norm_4_Cat using nuts2_shp, ///
    id(_ID) ///
    ocolor(black ..) fcolor("`colors'") osize(0.04 ..) ///
    ndocolor(black ..) ndfcolor(gs10 ..) ndsize(0.04 ..) ndlabel("Missing") ///
    legend(pos(11) size(*0.8)) legstyle(2)

    The result is attached below.

    I only would like to display labels in the legend. I would be very grateful for any advice.

  • #2
    You can use the -label()- option in legend. See: help legend_options

    Code:
    use "Italy-RegionsData.dta", clear
    
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)  /// 
        legend( label(5 "Group 1")  label( 4 "Group 2") /// 
        label(3 "Group 3") label(2 "Group 4") )

    Comment


    • #3
      Thank you Scott!

      Comment

      Working...
      X