mattflor / chorddiag

R interface to D3 chord diagrams
159 stars 44 forks source link

Label ordel #20

Open brunaw opened 6 years ago

brunaw commented 6 years ago

Hello!

Is there anyway I can reoder the labels? I noticed their appear in an alphabetical form, but for my case it would make more sense if the labels could be arranged in a specific way.

Thanks in advance.

mattflor commented 6 years ago

Do they? I don't think so. The order is determined by the matrix you pass to the chorddiag function (if I remember correctly).

See e.g.:

m <- matrix(500*seq.int(1, 16, by = 1),
            byrow = TRUE,
            nrow = 4, ncol = 4)
haircolors <- c("blonde", "red", "brown", "black")
dimnames(m) <- list(have = haircolors,
                    prefer = haircolors)
print(m)

groupColors <- c("#FFDD89", "#F26223", "#957244", "#000000")
chorddiag(m, groupColors = groupColors, groupnamePadding = 20,
          tickInterval = 500)

Groups start at the 12 o'clock position and then are placed clockwise...