# How can I use BarChart to add label of the range of each set of data on the x axis?

(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.

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

-

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}])]


-

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,
"ColorScheme" -> "BeachColors", "GradientOrigin" -> Top]]


-
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]


or framed?

-