What does it need to specify the category order in

2019-08-17 10:54发布

I created a colored and patterned pie chart as described in this stack exchange Question. Now I also want to specify an order of the categories to apear in the pie chart.

Usually this works with the sort.values funtion:

SCALE: cat(aesthetic(aesthetic.color), sort.values("value", "value",...))

However this function doesn't seem to have an effect when having both color(var)) and texture.pattern(var) functions inside the same ELEMENT-Statement.

1条回答
Animai°情兽
2楼-- · 2019-08-17 11:14

You also need to specify the category order for the texture.pattern. So add the line:

SCALE: cat(aesthetic(aesthetic.texture.pattern), sort.values("value", "value", ...))

Defining the category order for both, the color aesthetic and the texture.pattern aesthetic should result in the specific ordered pie chart.

Unfortunatly the order isn't applyied to the legend, which is quiet a bummer when trying to read the pie chart. I haven't figured out how or if this can be fixed.

查看更多
登录 后发表回答