Announcement

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

  • Color palette in SPMAP

    Hello statalisters

    I am creating several maps showing prison rates using Maurizio Pisati's user written command smpap in Stata 13 SE. I seem to have problems with the colors. I use fcolor(Blues) and custom color breaks to show intensity. The command draws the map but countries like the US or Russia, for example, do not appear with the highest intensity of the Blues color palette. I have tried different custom breaks without much luck. I run out of ideas to fix this.
    Any help will be greatly appreciated. Below I enclose the code i used to create the map




    #delimit;
    spmap prison using worldcoor.dta, id(id) fcolor(Blues)
    clmethod(custom) clbreaks(0 100 300 600 800)
    legend(symy(*2) symx(*2) size(*2) position (9))
    legorder(lohi) legend(label(2 "0 to 100") label(3 "100 to 300" )label(4 "300 to 600" )
    label(5 "600 to 800" ) size(vsmall))
    ;
    # delimit cr

  • #2
    Blues has 9 color levels. You have 5 cutpoints (so 5 or 6 levels, depending on your support of prison). Hence, it won't be using the darkest colors.

    To fix, change:
    fcolor(Blues)
    TO
    fcolor(blue*2.5 blue*2.0 blue*1.5 blue*1.0 blue*0.5 blue*0.3 blue*0.2)
    OR
    fcolor(blue*2.5 blue*2.0 blue*1.5 blue*1.0 blue*0.5 )

    Note, only the first N colors are used, so if you have more cutpoints, then you need more colors.

    This colorlist uses stata's "adjust intensity" feature for colors.




    This is the relevant colorlist or color template for the color lists. It's from the spmap helpfile. Sorry about the formatting. You can find the relevant section here: http://fmwww.bc.edu/repec/bocode/s/spmap.html


    Code:
    Some spmap options and suboptions request the user to specify a list of     one or more colors. When the list includes only one color, the user is     required to specify a standard colorstyle. On the other hand, when the     list includes two or more colors, the user can either specify a standard     colorstyle list, or specify the name of a predefined color scheme.
         The following table lists the predefined color schemes available in the     current version of spmap, indicating the name of each scheme, the maximum     number of different colors it allows, its type, and its source.
                            NAME     MAXCOL         TYPE     SOURCE                ------------------------------------------------                       Blues          9   Sequential     Brewer                      Blues2         99   Sequential     Custom                        BuGn          9   Sequential     Brewer                        BuPu          9   Sequential     Brewer                        GnBu          9   Sequential     Brewer                      Greens          9   Sequential     Brewer                     Greens2         99   Sequential     Custom                       Greys          9   Sequential     Brewer                      Greys2         99   Sequential     Brewer                        Heat         16   Sequential     Custom                        OrRd          9   Sequential     Brewer                     Oranges          9   Sequential     Brewer                        PuBu          9   Sequential     Brewer                      PuBuGn          9   Sequential     Brewer                        PuRd          9   Sequential     Brewer                     Purples          9   Sequential     Brewer                     Rainbow         99   Sequential     Custom                        RdPu          9   Sequential     Brewer                        Reds          9   Sequential     Brewer                       Reds2         99   Sequential     Custom                     Terrain         16   Sequential     Custom                 Topological         16   Sequential     Custom                        YlGn          9   Sequential     Brewer                      YlGnBu          9   Sequential     Brewer                      YlOrBr          9   Sequential     Brewer                      YlOrRd          9   Sequential     Brewer                        BrBG         11    Diverging     Brewer                        BuRd         11    Diverging     Custom                      BuYlRd         11    Diverging     Custom                        PRGn         11    Diverging     Brewer                        PiYG         11    Diverging     Brewer                        PuOr         11    Diverging     Brewer                        RdBu         11    Diverging     Brewer                        RdGy         11    Diverging     Brewer                      RdYlBu         11    Diverging     Brewer                      RdYlGn         11    Diverging     Brewer                    Spectral         11    Diverging     Brewer                      Accent          8  Qualitative     Brewer                       Dark2          8  Qualitative     Brewer                      Paired         12  Qualitative     Brewer                     Pastel1          9  Qualitative     Brewer                     Pastel2          8  Qualitative     Brewer                        Set1          9  Qualitative     Brewer                        Set2          8  Qualitative     Brewer                        Set3         12  Qualitative     Brewer                ------------------------------------------------

    Comment


    • #3
      This seems to be a belated answer to the question posted in October 2014 here:
      http://www.statalist.org/forums/foru...lette-in-spmap
      At that time Erik Alda seems to have found the solution to his problem.
      If not please explain.

      H C , I think you are misinterpreting the table. It shows the maximum number of different colors in the palette. Not the actual number. If your number of unique values is 3 the palette is going to be different from palette for 9 unique values.

      This can be seen in the ADePT Maps palette editor here (page 20):
      http://siteresources.worldbank.org/I...DePT_Maps2.pdf

      So in principle the palette can be configured to use the lightest and darkest colors for every number of colors bigger than 2. Whether the blues palette behaves exactly like that or not is not clear to me and may be version dependent. One can still do the correction you are suggesting, which boils down to using a new set of colors instead of the original blues palette and it will be specific to the breaks option.

      Best, Sergiy Radyakin

      Comment

      Working...
      X