8
$\begingroup$

V 12.1 on windows 10 shows extra space above and below BarChart3D compared to V 12 using the same code.

I'like to put a label above this one below, but the space always where the bars stop and the label is too large using V 12.1. This does not happen in V12. All on same PC.

I tried different ways to put the label, and still the empty space does not shrink. I tried Labeled also and Grid. Also tried adding ImageMargins -> 0, ImagePadding -> 0 as option to the BarChart3D command, but that had no effect on reducing the white space above and below.

Here is the one I am using now.

dataForChart = {{0.8, 0, 0, 99.2}, {14.285, 0, 0, 100}, 
   {28.571, 0, 14.285, 57.1428}, {0, 0, 0, 100}, {28.571,0, 14.2857, 57.142857}, 
   {28.5714,0, 0, 71.42857}, {57.14285, 0, 14.28571, 28.57142}};

casNames = {
   Text@Style["Rubi", Bold, 10],
   Text@Style["Mathematica", Bold, 10],
   Text@Style["Maple", Bold, 10],
   Text@Style["FriCAS", Bold, 10],
   Text@Style["Giac/Xcas", Bold, 10],
   Text@Style["Sympy", Bold, 10],
   Text@Style["Maxima", Bold, 10]
   };

percentageSolvedByRubi = 99.2;
percentageSolvedByM = 85.714;
percentageSolvedByMaple = 71.4286;
percentageSolvedByFricas = 100.;
percentageSolvedByGiac = 71.4286;
percentageSolvedBySympy = 71.4286;
percentageSolvedByMaxima = 42.8571;

Grid[
 {
  {Text[Style["Antiderivative Grade distribution for each CAS", 20]]},
  {Text[Style[
     "Numbers shown on bars are total percentage solved for each CAS",
      10]]},
  {
   BarChart3D[
    dataForChart,
    ChartLayout -> "Percentile",
    ChartStyle -> { Red,   
      RGBColor[255/255, 255/255, 0/255], 
      RGBColor[51/255, 51/255, 255/255], 
      RGBColor[50/255, 205/255, 50/255]},
    ChartLabels -> {Placed[casNames, Below ], None},
    ImageSize -> 500,
    FaceGrids -> None,
    Axes -> False,
    ChartBaseStyle -> EdgeForm[None],
    ImageSize -> 400,
    PlotRange -> {0, 110},
    BarSpacing -> 1.4, PlotTheme -> "Classic", Background -> None, 
    Lighting -> None, Method -> {"Canvas" -> None},
    ChartLegends -> {"F", "C", "B", "A"},
    Epilog -> {(*same order as names listed above*)
       Text[
       Style[ToString[Round[percentageSolvedByRubi, 0.01]] <> "%", 
        Bold], Scaled[{.14, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedByM, 0.01]] <> "%", Bold],
        Scaled[{.25, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedByMaple, 0.01]] <> "%", 
        Bold], Scaled[{.37, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedByFricas, 0.01]] <> "%", 
        Bold], Scaled[{.48, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedByGiac, 0.01]] <> "%", 
        Bold], Scaled[{.61, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedBySympy, 0.01]] <> "%", 
        Bold], Scaled[{.72, .6}]],
      Text[
       Style[ToString[Round[percentageSolvedByMaxima, 0.01]] <> "%", 
        Bold], Scaled[{.84, .6}]]
      }
    ]
   }
  }, Frame -> All, Spacings -> {1, 0}]

Running the above gives

enter image description here

Any suggestions what to do?

Thanks to comment by Kglr, I tried this on the cloud. The space is indeed gone, but the numbers on the bar charts are now shifted when compared to how they look in the notebook. This is all too strange.

enter image description here

Update:

I just found that this could be a bug! I tried the same code on V 12 on the same PC, and this is the output

enter image description here

Is this a bug??

$\endgroup$
  • 2
    $\begingroup$ probably os-related. No extra space on Wolfram Cloud. $\endgroup$ – kglr Apr 4 at 2:10
  • $\begingroup$ @kglr I think this a bug now ! I just tried the same code on V12 on same PC and it gives correct output. No extra space. $\endgroup$ – Nasser Apr 4 at 2:49
  • $\begingroup$ can you try if changing the Method option to Method -> {"Canvas" -> None, "ShrinkWrap" -> True} helps? $\endgroup$ – kglr Apr 4 at 3:29
  • $\begingroup$ @kglr thanks for the suggestion. I just did. No effect. $\endgroup$ – Nasser Apr 4 at 3:36
  • $\begingroup$ any reason for BarChart3D instead of BarChart? $\endgroup$ – kglr Apr 4 at 3:37
6
$\begingroup$

You can get the 3D look with BarChart using ChartElementFunction -> "ObliqueRectangle".

percentSolved = PercentForm /@ 
   ({42.857, 85.714, 71.4286, 100., 71.4286, 71.4286, 42.8571}/100); 

bc = BarChart[MapThread[Labeled, {dataForChart, casNames}], 
   ChartLayout -> "Percentile", 
   ChartStyle -> {Red, RGBColor[255/255, 255/255, 0/255], 
       RGBColor[51/255, 51/255, 255/255], 
       RGBColor[50/255, 205/255, 50/255]}, 
   ChartElementFunction -> "ObliqueRectangle",
   ChartLabels -> {Placed[percentSolved, {{.5, 1}, {.5, 5}}], None},
   ImageSize -> 500, Axes -> {True, False},
   AxesStyle -> Directive["LineColor" -> None],
   ChartBaseStyle -> EdgeForm[None],
   BarSpacing -> .4, PlotTheme -> "Classic",
   ChartLegends -> {"F", "C", "B", "A"}]

enter image description here

Grid[{{Text[Style["Antiderivative Grade distribution for each CAS", 20]]},
  {Text[Style["Numbers shown on bars are total percentage solved for each  CAS", 10]]}, 
  {bc}}, 
  Frame -> All, Spacings -> {1, 1}]

enter image description here

 $Version
"12.1.0 for Linux x86 (64-bit) (March 4, 2020)" (* Wolfram Cloud *)

In version 11.3.0 (Windows 10) change the definition of percentSolved to

percentSolved = Row[{Round[#, .01], "%"}] & /@
  {42.857, 85.714, 71.4286, 100., 71.4286, 71.4286, 42.8571};

to get

enter image description here

| improve this answer | |
$\endgroup$
5
$\begingroup$

Both methods used v. 12.1 on a Mac.

Method 1

You can get a slight improvement by adjusting the AspectRatio. For example, with AspectRatio->0.7, some space is removed. It also reduces the heights of the bars.

barchart 3D


Method 2: Rasterize the bar chart

barchart = BarChart3D[dataForChart,ImageSize -> 700,ChartLayout -> "Percentile", ChartStyle -> {Red, RGBColor[255/255, 255/255, 0/255], RGBColor[51/255, 51/255, 255/255], RGBColor[50/255, 205/255, 50/255]}, ChartLabels -> {Placed[casNames, Below], None}, FaceGrids -> None, Axes -> False, ChartBaseStyle -> EdgeForm[None], PlotRange -> {0, 110}, BarSpacing -> 1.4, PlotTheme -> "Classic", Background -> None, Lighting -> None, Method -> {"Canvas" -> None},ChartLegends -> {"F", "C", "B", "A"},Epilog -> {(*same order as names listed above*) Text[Style[ToString[Round[percentageSolvedByRubi, 0.01]] <> "%", Bold], Scaled[{.14, .6}]], Text[Style[ToString[Round[percentageSolvedByM, 0.01]] <> "%", Bold], Scaled[{.25, .6}]], Text[Style[ToString[Round[percentageSolvedByMaple, 0.01]] <> "%",Bold], Scaled[{.37, .6}]], Text[Style[ToString[Round[percentageSolvedByFricas, 0.01]] <> "%", Bold], Scaled[{.48, .6}]],Text[Style[ToString[Round[percentageSolvedByGiac, 0.01]] <> "%",Bold], Scaled[{.61, .6}]],Text[Style[ToString[Round[percentageSolvedBySympy, 0.01]] <> "%",Bold], Scaled[{.72, .6}]], Text[Style[ToString[Round[percentageSolvedByMaxima, 0.01]] <> "%", Bold], Scaled[{.84, .6}]]}];

i = Pane[ImageTrim[Rasterize[barchart],{{10, 200}, {1800, 1100}}]];

Grid[{{Text[Style["Antiderivative Grade distribution for each CAS", 20]]}, {Text[Style["Numbers shown on bars are total percentage solved for each CAS", 10]]}, {i}}, Frame -> All, Spacings -> {1, 1}, ItemSize -> Full]

image2

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the idea. But this makes the bars also smaller and little harder to see the numbers and the space is still too large compared to V 12. $\endgroup$ – Nasser Apr 4 at 2:57
  • 1
    $\begingroup$ I added a second approach. $\endgroup$ – DavidC Apr 4 at 4:10

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.