6
$\begingroup$

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?

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

$\endgroup$
0
$\begingroup$
styleddata = data;
styleddata[[All, -1]] = Style[#, EdgeForm[{Thick, Dashed}]] & /@ styleddata[[All, -1]];

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

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.