Message Boards Message Boards

0
|
2851 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to group the labels in BarChart?

I want to generate the following bar chart, and I need to group the labels. How should it be done?

data = {{RandomInteger[{0, 100}, 100],RandomInteger[{0, 100}, 100], 
    RandomInteger[{0, 100}, 100]}, {RandomInteger[{0, 100}, 100], 
    RandomInteger[{0, 100}, 100]}};
BoxWhiskerChart[data, 
 ChartLabels -> {{"Group1", "Group2"}, {"a", "b", "c", "d", "e"}}]

enter image description here

POSTED BY: Tsai Ming-Chou
3 Replies
Posted 2 years ago

Hi Ming-Chou,

I have run into this issue before. Here is a workaround using a custom LabelingFunction, but it does not quite match your requirements.

labels = {{"Group1", "Group2"}, {{"a", "b", "c"}, {"d", "e"}}}
BoxWhiskerChart[data,
 ChartLabels -> {First@labels, None},
 LabelingFunction -> (Placed[labels[[2]][[##]] & @@ #2, Below] &)]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi

Hi Rohit Namjoshi:
I did ask this question repeatedly in two forums!
When I have a problem I can't solve, I always look for a similar paradigm in both forms ~~
Because this problem has been bothering me for a long time!
Sorry if I cause people any trouble~~

Thank you for giving me this idea~~
It is very important to me~~

POSTED BY: Tsai Ming-Chou
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract