Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have multiple dataset that I want to plot in PieChart, as in

PieChart[{{2, 2}, {1, 2, 4}}, ChartLayout -> "Stacked"]

Now here is the catch: I want the color of the chart to be "similar" if the corresponding data belong to the same set. In my example, the regions corresponding to {1,2,4} would have different shades of Blue, while the ones relative to {2,2} would be plotted with different intensities of Red.

Finally, since the original data set is more nested than this one, it would be nice to be able to specialize such color function further

I have tried with ColorFunction -> Function[x, ...] but I don't manage to have info about the originating dataset.

Example or more nested data set:

{{2, 2}, {1, 2, {3,1}}}
{{2, 2}, {1, 2, {{2,1},1}}}
share|improve this question
    
I don't have an answer. But a link about pie charts, and how there is usually a better way to present data junkcharts.typepad.com/junk_charts/2011/10/… –  Cameron Murray Feb 26 at 23:22

1 Answer 1

I guess that the answer is similar to the one given in this answer, which is my case is

style1 = {Lighter@Red, Red, Darker@Red}
style2 = {Lighter@Blue, Blue, Darker@Blue}
data = {{2, 1, 1}, {1, 2, 4}}
PieChart[MapThread[Style, {data, {style1, style2}}, 2], ChartLayout -> "Stacked"]

enter image description here

Note that I am cheating because I made the data a square matrix to avoid problems with MapThread.

I think it is possible to generalize this method to more nested dataset with a little patience.

For larger dataset the result can be confusing and not so clear

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.