12
$\begingroup$

Bug introduced in 10.0.0 and fixed in 10.0.1


BarChart formatting algorithm make me loose some time today in V10. Now, LabelingFunction does not work beyond some number of Labels. See example:

RandomSeed[1]
barchart[n_]:=
    BarChart[RandomInteger[10,{n,3}]
            ,LabelingFunction->(Placed[#1,Center]&)
            ,AspectRatio->0.2,ImageSize->700
            ,ChartLayout->"Percentile"
    ]

barchart[33]
barchart[34]

enter image description here

After 33, labels disappear!

Which magic parameter can I change to get my labels back? The problem is the same in V10.0.0 for Mac and Win.

I wrote to support. If I get some clue I'll post here.

$\endgroup$

3 Answers 3

6
$\begingroup$

A workaround is just to use multiple bar charts for the data

RandomSeed[1];
Clear[barchart];
barchart[n_, partitions_: 1] := Module[
  {m = Ceiling[n/partitions]},
  BarChart[
      #,
      LabelingFunction -> (Placed[#1, Center] &),
      AspectRatio -> 0.2,
      ImageSize -> 700,
      ChartLayout -> "Percentile"] & /@
    Partition[
     Join[
      RandomInteger[10, {n, 3}],
      Table["", {m - 1}]],
     m] //
   Column]

barchart[33]

enter image description here

barchart[51, 2]

enter image description here

$\endgroup$
6
$\begingroup$

The maximum number of labeled bars in Version 10.0.0 seems to be limited to 99 when LabelingFunction is used. An alternative work-around is to wrap data with Labeled:

RandomSeed[1]
barchart2[n_,m_]:=  Module[{dt=RandomInteger[10,{n,m}]},  
       BarChart[Labeled[#,#,Center]&/@#&/@dt,
                AspectRatio->0.2,ImageSize->700,
                ChartLayout->"Percentile" ]]

barchart2[34,3]

enter image description here

barchart2[50, 5]

enter image description here

$\endgroup$
3
  • $\begingroup$ After a native option to change this behavior, I think this is a good option. +1 $\endgroup$
    – Murta
    Commented Jul 19, 2014 at 11:49
  • $\begingroup$ Please reconsider deleting this. This is an effective workaround for pre-v10.0.1. $\endgroup$
    – rcollyer
    Commented Sep 17, 2014 at 13:44
  • $\begingroup$ @rcollyer, thank you for the vote. just rolled back the delete. $\endgroup$
    – kglr
    Commented Sep 17, 2014 at 14:15
5
$\begingroup$

The behavior was corrected in Mathematica 10.0.1.

Using the same example:

    RandomSeed[1]
barchart[n_]:=
    BarChart[RandomInteger[10,{n,3}]
            ,LabelingFunction->(Placed[#1,Center]&)
            ,AspectRatio->0.2,ImageSize->700
            ,ChartLayout->"Percentile"
    ]

barchart[33]
barchart[100]

We now have: enter image description here

My tks to Wolfram team!

$\endgroup$
4
  • 1
    $\begingroup$ Note: with ChartLayout -> "Stacked" and "Percentile" labels are not labeled. $\endgroup$
    – rcollyer
    Commented Sep 17, 2014 at 13:44
  • $\begingroup$ Thanks for posting this notification. $\endgroup$
    – Mr.Wizard
    Commented Sep 17, 2014 at 14:20
  • $\begingroup$ @rcollyer Stacked and Percentile worked nice to me in V10.0.1. $\endgroup$
    – Murta
    Commented Sep 17, 2014 at 20:02
  • $\begingroup$ They'll work, but the zero height bars aren't labeled. Just a warning. $\endgroup$
    – rcollyer
    Commented Sep 17, 2014 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.