Announcement

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

  • How to select colors of colorpalette: ipolate in a stacked bar graph

    Hi,
    I would like to create a stacked bar graph of 30 different types of expenditures over time using the ipolate option of colorpalette.
    I have two questions:

    1) How can I select the 30 different colors shown in the colorpalette graph?

    2) How can I use the variable label (of each of the 30 ) as a bar label for each category shown in the bar graph. Using the blabel(name) option only shows the variable names.


    Code:
                        colorpalette: DarkCyan FloralWhite DarkGoldenRod, ipolate(30, power(1.5)) 
    
                        graph bar category1 category2 .....category30, over(month) stack blabel(name, color(black) position(inside))
    Any ideas?

    Best wishes,
    Steve

  • #2
    I solved problem #1 by simply dropping ":" after the colorpalette command. In doing so, the (internally stored) locals can be retrieved for each bar, as shown below.

    Code:
    colorpalette DarkCyan FloralWhite DarkGoldenRod, ipolate(30) 
    #delimit ;
    graph bar amount_kat2_* , over(month) stack
                                bar(1, c("`r(p1)'")) bar(2, c("`r(p2)'")) bar(3, c("`r(p3)'")) bar(4, c("`r(p4)'")) bar(5, c("`r(p5)'")) bar(6, c("`r(p6)'"))  bar(7, c("`r(p7)'")) 
                                bar(8, c("`r(p8)'")) bar(9, c("`r(p9)'")) bar(10, c("`r(p10)'")) bar(1, c("`r(p11)'")) bar(12, c("`r(p12)'")) bar(13, c("`r(p13)'"))  bar(14, c("`r(p14)'")) 
                                bar(15, c("`r(p15)'")) bar(16, c("`r(p16)'")) bar(17, c("`r(p17)'")) bar(18, c("`r(p18)'")) bar(19, c("`r(p19)'")) bar(20, c("`r(p20)'"))  bar(21, c("`r(p21)'")) 
                                bar(22, c("`r(p22)'")) bar(23, c("`r(p23)'")) bar(24, c("`r(p24)'")) bar(25, c("`r(p25)'")) bar(26, c("`r(p26)'")) bar(27, c("`r(p27)'"))  bar(28, c("`r(p28)'")) 
                                bar(29, c("`r(p29)'")) bar(30, c("`r(p30)'"))
                                blabel(bar, gap(0) color(black) position(inside) size(1));
    #delimit cr

    Comment

    Working...
    X