2
$\begingroup$

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}}}
$\endgroup$
1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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