Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

(My code:)

DataFirst = {0, -1, 0.5, 1, -4.5, 4.5, -0.5, 6, -4.5, 0, -1.5, 
             1.5, -0.5, 2.5, 0, 2, -1, 2, -1, 2, -6.5, -3, 2.5, -3, -0.5, 2.5, 
             5, 2.5, -3, -2.5, 1.5, -2, 2, -0.5, 3.5, -2.5, 2.5, -1, 
             1.5, -1, -3.5, 1.5, -1, -1, -2, 5.5, 4, 1.5, -6, -1.5, 0, -1, 2, 4,
             3, -2, -0.5, 0.5, -0.5, 0, -0.5, -1, 2, -5, 2.5, 2.5, 
             7, -2, -2.5, -2.5, 2, -2.5, 4, 2, 4, -5, 1.5, -1.5, 2, -2.5, -3, 
             2, -1, -2.5, 1, 5, 3, -0.5, -2.5, 0.5, -0.5, 1, 0.5, 4, -0.5, 
             1, -1, 1.5, 0.5, 2.5};
max = Max[DataFirst];
min = Min[DataFirst];
dx = (max - min)/10;
fi = BinCounts[DataFirst, {min, max, dx}]
BarChart[fi]

I want to show the range of each set of data on the x axis.

enter image description here

for example,min to min+dx, min+dx to min+2*dx and so on until min+9 *dx to max *)

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

Using ChartLabels is another way, apart from what Nasser suggests, to achieve this:

BarChart[fi, 
 ChartLabels -> (Rotate[#, Pi/4] & /@ 
    Table[ToString[x] <> " to " <> ToString[x + dx], {x, min, max, 
      dx}])]

barchart

share|improve this answer
add comment

There could be many possible solutions. Basically you have to design your own labels. For example:

lbls = (ToString[#[[1]]] <> " | " <> ToString[#[[2]]]) & /@ 
        Partition[Range[min, max, dx], 2, 1] 

I am using "|" as separator. Then just

BarChart[fi, AspectRatio -> 1/5, ImageSize -> 800, ChartLabels -> lbls, 
 ChartElementFunction -> ChartElementData["GradientRectangle", 
   "ColorScheme" -> "BeachColors", "GradientOrigin" -> Top]]

enter image description here

share|improve this answer
add comment
DataFirst = {0, -1, 0.5, 1, -4.5, 4.5, -0.5, 6, -4.5, 0, -1.5, 
   1.5, -0.5, 2.5, 0, 2, -1, 2, -1, 2, -6.5, -3, 2.5, -3, -0.5, 2.5, 
   5, 2.5, -3, -2.5, 1.5, -2, 2, -0.5, 3.5, -2.5, 2.5, -1, 
   1.5, -1, -3.5, 1.5, -1, -1, -2, 5.5, 4, 1.5, -6, -1.5, 0, -1, 2, 4,
    3, -2, -0.5, 0.5, -0.5, 0, -0.5, -1, 2, -5, 2.5, 2.5, 
   7, -2, -2.5, -2.5, 2, -2.5, 4, 2, 4, -5, 1.5, -1.5, 2, -2.5, -3, 
   2, -1, -2.5, 1, 5, 3, -0.5, -2.5, 0.5, -0.5, 1, 0.5, 4, -0.5, 
   1, -1, 1.5, 0.5, 2.5};
max = Max[DataFirst];
min = Min[DataFirst];
dx = (max - min)/10;
fi = BinCounts[DataFirst, {min, max, dx}]
fi = Table[Labeled[fi[[i]],Style[Rotate[
      Row[{"(", min + (dx*i-1), ",", min + dx*i, ")", Spacer[10]}], 
      90 Degree], 14]], {i, 0, Length[fi]}];

BarChart[fi]

the modified picture

or framed?

Mathematica graphics

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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