6
$\begingroup$

For big numbers of columns, a stacked BarChart does not display edges anymore. For low numbers of columns they appear again. Is there a way to force Mathematica displaying the edges, even for big lists?

Here is an example:

no edges:

BarChart[Table[RandomReal[9], {i, 35}, {j, 11}], 
ChartLayout -> "Stacked", BarSpacing -> None]

with edges:

BarChart[Table[RandomReal[9], {i, 5}, {j, 11}], 
ChartLayout -> "Stacked", BarSpacing -> None]

Thank you very much for your help!!

All the best, Kilian

$\endgroup$
4
$\begingroup$
bc = BarChart[Table[RandomReal[9], {i, 35}, {j, 11}], 
   ChartLayout -> "Stacked", BarSpacing -> None]

enter image description here

Somehow, the rectangles are rendered with the directive

EdgeForm[Directive[Opacity[0.]]

when the input data is larger than some threshold.

You can post-process the output to change Opacity[0.] to Opacity[1.]:

bc /.  Opacity[0.] -> Opacity[1.]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much... You rescue my evening;) Good job!! $\endgroup$ – Kilian Jun 19 '18 at 20:32
  • $\begingroup$ @Kilian, glad it was useful. Thank you for the accept. $\endgroup$ – kglr Jun 19 '18 at 20:38
2
$\begingroup$

I think @kglr has hit on the core issue of the problem by noting the addition of the Opacity directive once you cross a threshold.

If you want to include the solution in the code, you can specify it with ChartStyle andEdgeForm directly.

BarChart[Table[RandomReal[9], {i, 35}, {j, 11}], 
 ChartLayout -> "Stacked", BarSpacing -> None, 
 ChartStyle -> EdgeForm[{Thin, Opacity[1]}]]
$\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.