6

I would like to change every second member of a pair in a BoxWhiskerChart to have a dashed EdgeForm.

I can create a chart where all the boxes have the dashed EdgeForm. For example, the following creates four pairs of data blocks, and colors each block a particular color,

data = Table[RandomVariate[NormalDistribution[a, 1], 100], {a, {0, 3, 2, 5}}, {2}];

BoxWhiskerChart[data, ChartStyle -> {{Red, Green, Blue, Black}, None}, 
       ChartBaseStyle -> EdgeForm[Dashed]]

which creates a chart that will look something like, enter image description here

However I don't know how to change the EdgeForm to dashed for only every second member of each pair.

Does anyone know how I can do this?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
ben18785
  • 3,167
  • 15
  • 28

2 Answers2

4
BoxWhiskerChart[data, 
 ChartStyle -> {{Red, Green, Blue, Black}, {EdgeForm[Thick], EdgeForm[Dashed]}}]

enter image description here

Or

Show[{
  BoxWhiskerChart[ReplacePart[data, {i_, 2} -> None], 
   ChartStyle -> {{Red, Green, Blue, Black}, None}, 
   ChartBaseStyle -> EdgeForm[Thick]],
  BoxWhiskerChart[ReplacePart[data, {i_, 1} -> None], 
   ChartStyle -> {{Red, Green, Blue, Black}, None}, 
   ChartBaseStyle -> EdgeForm[Dashed]]
  }]

Out

Karsten7
  • 27,448
  • 5
  • 73
  • 134
0
styleddata = data;
styleddata[[All, -1]] = Style[#, EdgeForm[{Thick, Dashed}]] & /@ styleddata[[All, -1]];

BoxWhiskerChart[styleddata, ChartStyle -> {{Red, Green, Blue, Black}, None}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896