1
$\begingroup$

I have two data sets that I use to build a histogram in the following code:

   HistMagEstac = 
 BarChart[{eventosporclasses}, 
  ChartLabels -> Placed[Classes, Below, Rotate[#, Pi/2.4] &], 
  ChartElementFunction -> "ObliqueRectangle", 
  PlotLabel -> 
   Style["Distribuição de magnitudes (2014) ->  atualização de: " <> 
     DateString[{"Day", "/", "Month", "/", "Year", " às ", 
       "HourShort", ":", "MinuteShort"}], "Title", 16], 
  ColorFunction -> Function[{height}, ColorData["Rainbow"][height]], 
  AxesLabel -> {Style["Mag/10", 12, Bold], 
    Style["Total de mag. por classe", 12, Bold]}, 
  LabelingFunction -> Above, ImageSize ->  800]

But, when the histogram is created, labels related to zero values, are not being written: see the picture

Am I doing something wrong? Also, I`d like to set the labels in the middle of each class limits.

The resulting histogram: enter image description here

The data set:

eventosporclasses =   {0, 1, 2, 1, 5, 5, 3, 5, 15, 30, 50, 115, 248, 581, 1063, 1606, 2022, \
1584, 1027, 862, 1095, 823, 361, 65, 7, 1, 0, 1, 0, 4, 7, 0, 6, 14, \
3, 0, 1};



 Classes = {"-80 a -76", "-75 a -71", "-70 a -66", "-65 a -61", 
       "-60 a -56", "-55 a -51", "-50 a -46", "-45 a -41", "-40 a -36", 
       "-35 a -31", "-30 a -26", "-25 a -21", "-20 a -16", "-15 a -11", 
       "-10 a -6", "-5 a -1", "00 a 4", "5 a 9", "10 a 14", "15 a 19", 
       "20 a 24", "25 a 29", "30 a 34", "35 a 39", "40 a 44", "45 a 49", 
       "50 a 54", "55 a 59", "60 a 64", "65 a 69", "70 a 74", "75 a 79", 
       "80 a 84", "85 a 89", "90 a 94", "95 a 99", "100 a 105"};
$\endgroup$
  • $\begingroup$ this works well in version 10 and fails in version 9. $\endgroup$ – Zviovich Nov 18 '14 at 17:37
  • $\begingroup$ Maybe a bug? I didnt try in version 9 $\endgroup$ – locometro Nov 18 '14 at 17:39
1
$\begingroup$

For version 9, wrapping data with Labeled gives the desired result:

BarChart[{Labeled @@@ Transpose[{eventosporclasses, Rotate[#, Pi/2.4] & /@ Classes}]}, 
 ChartElementFunction -> "ObliqueRectangle", 
 PlotLabel ->  Style["Distribuição de magnitudes (2014) ->  atualização de: " <> 
    DateString[{"Day", "/", "Month", "/", "Year", " às ", "HourShort",
       ":", "MinuteShort"}], "Title", 16], 
 ColorFunction -> Function[{height}, ColorData["Rainbow"][height]], 
 AxesLabel -> {Style["Mag/10", 12, Bold], 
   Style["Total de mag. por classe", 12, Bold]}, 
 LabelingFunction -> Above, ImageSize -> 800]

Mathematica graphics

$\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.