Announcement

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

  • spmap proportions overlay

    Dear All,

    my question is a follow up to this thread:
    https://www.stata.com/statalist/arch.../msg01152.html

    Consider the following code:
    Code:
    use "Italy-RegionsData.dta", clear
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       legstyle(3)                                                ///      
       diagram(variable(relig1) range(0 100) refweight(pop98)     ///
       xcoord(xcoord) ycoord(ycoord) fcolor(red) type(frect)) ///
       name(gbar)
      
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       legstyle(3)                                                ///      
       diagram(variable(relig1) range(0 100) refweight(pop98)     ///
       xcoord(xcoord) ycoord(ycoord) fcolor(red) type(pie)) ///
       name(gpie)
    
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       legstyle(3)                                                ///      
       diagram(variable(relig1 relig2 relig3) range(0 100) refweight(pop98)     ///
       xcoord(xcoord) ycoord(ycoord) fcolor(red) type(pie)) ///
       name(gpie3)
    
      
    graph combine gbar gpie gpie3, rows(1) xsize(3) ysize(1)
    This results in the following image:





    My problem with the left panel is the line that doesn't belong there. How to switch it off?
    My problem with the middle panel is the charts are all showing 100%, which is different from what the data and the left panel say. How to draw correct pie chart overlays reflecting the proportion of variable relig1?
    My problem with the right panel is that I only see 2 sectors on pie charts whereas 3 variables were specified (and none of the three is a trivial variable). Why are there only 2 sectors on the pie charts?

    Thank you, Sergiy

    Stata 16.0 (win) + user-written spmap Version 1.3.2 from here http://fmwww.bc.edu/RePEc/bocode/s/

  • #2
    1. add refcolor(none)
    2. You need more than 1 variable for the pie chart.
    3. Remove the fcolor() in the diagramI()

    Code:
    use "Italy-RegionsData.dta", clear
    gen not_relig1 = 100- relig1
    
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       legstyle(3)                                                ///      
       diagram(variable(relig1) range(0 100) refweight(pop98)     ///
       legstyle(3)                                                ///      
       diagram(variable(relig1 not_relig1) range(0 100) ///
       xcoord(xcoord) ycoord(ycoord) fcolor(red)                  ///
       refcolor(none) type(frect))                                 ///
       name(gbar, replace)
      
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       refweight(pop98)     ///
       xcoord(xcoord) ycoord(ycoord) fcolor(red) type(pie)) ///
       name(gpie, replace)
    
    spmap relig1 using "Italy-RegionsCoordinates.dta", id(id)     ///
       clnumber(5) fcolor(Reds2) ocolor(none ..)                  ///
       title("Pct. Catholics without reservations", size(*0.8))   ///
       subtitle("Italy, 1994-98" " ", size(*0.8))                 ///
       legstyle(3)                                                ///      
       diagram(variable(relig1 relig2 relig3) range(0 100) refweight(pop98)     ///
       xcoord(xcoord) ycoord(ycoord)  type(pie)) ///
       name(gpie3, replace)
     
       
      
    graph combine gbar gpie gpie3, rows(1) xsize(3) ysize(1)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	104.1 KB
ID:	1527797

    Comment

    Working...
    X