2

Bug introduced in 9.0 and fixed in 9.0.1


I want to generate a simple 3D view of some frequencies for two variables. I have the counts in a 4x3 matrix, say. This is my bar chart code:

BarChart3D[
 Map[Labeled[#, Text[Style[#, Black, Opacity[1.], Bold, 20]], 
    Above] &, {{1, 0, 2}, {0, 0, 2}, {2, 1, 0}, {0, 2, 1}}, {2}],
 ChartLayout -> "Grid",
 BarSpacing -> Large,
 ChartElements -> Graphics3D[Cylinder[]],
 ChartStyle -> Directive[Opacity[0.3]],
 AxesLabel -> {None, None, None},
 Ticks -> {{{1/2, "Del"}, {2, "Nor"}, {2 + 3/2, "Amp"}},
   {{1/2, "Osteo"}, {1.75, "Ewing"}, {3, "Rhabdo"}, {4.25, 
     "Neuro"}}, {0, 1, 2}},
 ViewPoint -> {1.3`, -2.4`, 2.`}
 ]

And this is what I got with Mathematica 9.0 (more precisely, 9.0.0.0 Mac OS X.)

Mathematica graphics

  • First, for readability, I want to place a label in each column. But as you can see, zeroes are not displayed. How can I get BarChart3D to plot my zeros? Or probably better, to draw a flat disk in corresponding place.
  • (Not as important) Notice how I placed the ticks for the x and y axes. The matrix is 4x3, so I don't understand where those positions come from (the ones I had to use to put the labels - see Ticks above). My guess is that my positions are probably wrong, although visually seem ok for now.

Help would be much appreciated.

Update

As workaround for zeros, I put a If[#==0,0.01,Labeled[...]] in Map and displays ok. Still, I am intrigued on how to position tick labels correctly, with Ticks or some other option.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
carlosayam
  • 2,080
  • 16
  • 21

2 Answers2

1

This is what I get using Mathematica version 7:

enter image description here

Probably behavior was changed, but in case it's only an option these are the option values:

Options[BarChart3D]

{AlignmentPoint -> Center, AspectRatio -> Automatic, Axes -> True, AxesEdge -> Automatic, 
 AxesLabel -> None, AxesOrigin -> Automatic, AxesStyle -> {}, Background -> None, 
 BaselinePosition -> Automatic, BaseStyle -> {}, Boxed -> False, BoxRatios -> Automatic, 
 BoxStyle -> {}, ColorOutput -> Automatic, ContentSelectable -> Automatic, 
 ControllerLinking -> Automatic, ControllerMethod -> Automatic, 
 ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic, 
 DisplayFunction :> $DisplayFunction, Epilog -> {}, FaceGrids -> Automatic, 
 FaceGridsStyle -> {}, FormatType :> TraditionalForm, ImageMargins -> 0., 
 ImagePadding -> All, ImageSize -> Automatic, LabelStyle -> {}, Lighting -> "Neutral", 
 Method -> Automatic, PlotLabel -> None, PlotRange -> All, PlotRangePadding -> Automatic, 
 PlotRegion -> Automatic, PreserveImageOptions -> Automatic, Prolog -> {}, 
 RotationAction -> "Fit", SphericalRegion -> False, Ticks -> Automatic, TicksStyle -> {}, 
 ViewAngle -> Automatic, ViewCenter -> Automatic, ViewMatrix -> Automatic, 
 ViewPoint -> Automatic, ViewRange -> All, ViewVector -> Automatic, 
 ViewVertical -> {0, 0, 1}, ChartBaseStyle -> Automatic, ChartStyle -> Automatic, 
 BarOrigin -> Bottom, ChartElements -> Automatic, BarSpacing -> Automatic, 
 ColorFunction -> Automatic, ColorFunctionScaling -> True, ChartLayout -> Automatic, 
 LabelingFunction -> Automatic, ChartElementFunction -> Automatic, ChartLabels -> None, 
 ViewPoint -> Automatic, ChartLegends -> None, PerformanceGoal :> $PerformanceGoal, 
 LegendAppearance -> Automatic}
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • Thanks @Mr.Wizard, I have version 9.0.0.0 and it seems behaviour changed. I am happy with my workaround tough. If you can shed light on how to place the labels I will give you the answer; my current manual placing is not portable to other NxM matrices, which is bad. Cheers! – carlosayam Jan 30 '14 at 22:56
0

Thanks all for feedback.

As per zeros not appearing, this is certainly a bug in 9.0.0 Mac. I have upgraded to 9.0.1 and now zeros are displayed.

As per the ticks, the approach was to use ChartLabels along with Placed.

BarChart3D[
 Map[Labeled[#, Text[Style[#, Black, Opacity[1.], Bold, 20]], 
    Above] &, {{1, 0, 2}, {0, 0, 2}, {2, 1, 0}, {0, 2, 1}}, {2}], 
 ChartLayout -> "Grid", BarSpacing -> Large,
 ChartElements -> Graphics3D[Cylinder[]],
 ChartStyle -> Directive[Opacity[0.3]], 
 AxesLabel -> {None, None, None},
 Ticks -> {None, None, {0, 1, 2}},
 ChartLabels -> {Placed[{"Osteo", "Ewing", "Rhabdo", "Neuro"}, Axis], {"Del", "Norm", "Amp"}},
 ViewPoint -> {1.3`, -2.4`, 2.`}]

which produces

Mathematica graphics

Positioning of labels can be improved I imagine (on the Y axis, specially); but I have tried other approaches mentioned in SE here and don't seem to work for 3D graphics.

Using Ticks as I did before placed the labels much better :( although those odd looking positions are still puzzling me.

Could someone improve on this? :)

carlosayam
  • 2,080
  • 16
  • 21