Announcement

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

  • pie chart - same colours for values

    Hi all,

    I am making several pie charts and I want the colours to be comparable across charts.

    My data looks roughly as follows:

    game winner1 winner2 n
    1 rob rob 1
    2 rob rob 1
    3 rob rob 1
    4 sarah rob 1
    5 sarah sarah 1
    6 sarah sarah 1
    7 jon sarah 1
    8 jon martin 1
    9 jon martin 1
    10 matt martin 1
    11 matt martin 1
    12 matt martin 1

    The names are simply values - suppose rob=1 sarah=2 jon=3 matt=4 martin=5

    Notice how "martin" didn't win any games in the first round, and "matt" didn't win any in the second. n is a column of 1s that allows me to make the pie chart.

    I am using -graph pie n,over(winner1)- and -graph pie n,over(winner2)- but when I do this the pie for "jon" is the same colour as the pie for "martin" because it is the third pie.

    Essentially, I want to specify that the pie colour is red if ="rob" etc.

    Any help would be great.

    I know from looking that Nick Cox thinks pie charts should be used for primary school children and senior executives only. The graphs are for the latter.

    Thanks

    Rob


  • #2
    I could not have put it better myself. Apart from considering something more civilised, a reshaping of the data seems called for. That way, your separate pie charts know about each other.

    Code:
    clear 
    input game str5 winner1 str6 winner2 n
    1 rob rob 1
    2 rob rob 1
    3 rob rob 1
    4 sarah rob 1
    5 sarah sarah 1
    6 sarah sarah 1
    7 jon sarah 1
    8 jon martin 1
    9 jon martin 1
    10 matt martin 1
    11 matt martin 1
    12 matt martin 1
    end 
     
    reshape long winner, i(game) 
    graph pie n, over(winner) by(_j)

    Comment

    Working...
    X