mpl_chord_diagram
mpl_chord_diagram copied to clipboard
Unique arc colors
Added possibility to give longer chord_colors list to define each separated arc color.
Now each arc calculates individual color from chord_colors list. If list is shorter then color is selected modulo list length.
ps. Examples also updated with 5-th example with different arc colors test.
Hi @folkien thanks for the PR! Being able to set specific colors for chords is definitely a useful addition.
However, I wonder whether this is the best way to add it, as it feels unlikely that people would set all individual chords' colors, and a flat list is not the most convenient way to specify which chords should be colored as we start from a matrix.
I would propose to request a
defaultdictaccepting(i, j)and(rowname, colname)as keys (so the default color can be chosen by the user).In case you haven't used
defaultdictbefore, it would go like:from collections import defaultdict ccolors = defaultdict(lambda: "grey", {(0, 1): "blue", (1, 2): "red"}) # default color is grey print(ccolors[(0, 0)]) # grey print(ccolors[(0, 1)]) # blue
To be honest, for me using this dict it's overengineering this feature. Default mechanism of cmap and chord_colors are very good in many situations. But for me, i would like to specify arc colors beause i'm using this chart for traffic intersection diagram where every traffic relation has own individual color. So i have to specify every arc color anyway.
Example
To be honest, for me using this dict it's overengineering this feature. Default mechanism of cmap and
chord_colorsare very good in many situations. But for me, i would like to specify arc colors beause i'm using this chart for traffic intersection diagram where every traffic relation has own individual color. So i have to specify every arc color anyway.
I understand that you have a specific use case, however, I'm not comfortable with the way the feature is implemented at the moment as it's not generic enough to accommodate other use cases that I feel should be supported if we include a "color specific chords" feature.
Would it really be that cumbersome for you to switch to a dict format? (if all entries are provided, it does not need to be a defaultdict)
Pinging @gph82 to hear his opinion on the PR.
Changes added today.
ideogram_colorsargument addedchord_colorscan be specified per node or per arc or per everything,
@folkien sorry, it seems Guillermo is not available at the moment I have a deadline on February 9 so I'll look at this afterwards. Just to clarify one thing: if I were to adapt the PR to use a dictionary myself, would it be OK for you or do you have a strong preference for a list?