6

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

kglr
  • 394,356
  • 18
  • 477
  • 896
Kilian
  • 145
  • 4

2 Answers2

4
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

kglr
  • 394,356
  • 18
  • 477
  • 896
2

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]}]]
kickert
  • 1,820
  • 8
  • 22