# How to get data from Histogram (HistogramList) for making plot?

I have a data I need to calculate the probability of the second column of my data in different bins and then getting(-LOG) from this probability and plot with the each bin related to it. my data is look like this:

   1      13.7449        35.5070
2      13.8816        35.9064
3      13.9259        35.5089
4      14.0310        35.8797
5      13.6690        33.7623
6      13.7621        34.4974
7      13.6607        33.6500
8      13.7123        33.5097
9      13.8104        33.5731
10      13.8473        33.3820
11      13.9361        34.7384
12      13.7765        33.4982
13      13.7131        33.6539
14      13.9118        34.3749
15      14.0458        34.9202
16      13.7972        33.2319
17      13.7900        34.3764
18      13.9416        34.6578
19      13.8032        33.7831
20      13.7993        34.4847
21      13.8143        35.0178
22      13.9709        35.1260
23      14.1073        35.0835
24      14.4144        35.5049
25      14.4046        35.2827
26      14.5538        37.0519
27      14.5542        37.0251
28      14.5442        36.0764
29      14.6055        36.1236
30      14.5951        36.9840
31      14.8370        37.6942
32      14.5325        36.7857
33      14.5348        36.8611
34      14.7832        38.0085
35      15.0101        39.4358
36      14.9237        39.1048
37      14.6539        37.0730
38      14.9132        37.9733
39      14.8029        38.2543
40      14.8276        38.1984


and the range of the second column can change from 8 to 40.

ROGU = Import["RoGu.dat", "Table"];
ROGU = Map[#[[2]] &, ROGU];
{bins, counts} = HistogramList[{ROGU}, {8, 40, 2}, "Probability"];
HistogramL[{ROGU}, {8, 40, 2}, "Probability"]


If I understand your question correctly, I think you can just throw your data into a Histogram directly and specify the correct options to get what you want. Make sure you have your data specified as data = {{x1, y1}, {x2, y2}, ...} and then call:

Histogram[
data,
Automatic,
"Probability",
ScalingFunctions -> {-Log[#] &, Exp[-#] &}
]


Copy paste example:

Histogram[RandomVariate[NormalDistribution[2, 1], 1000],
Automatic,
"Probability",
ScalingFunctions -> {-Log[#] &, Exp[-#] &}
]

• Thank you, Sjoerd Smit , it is very helpful but I need to be able to control the size of the bins also my data look like this 1 26.8283 48.4646 2 26.4985 48.7885 3 26.6306 48.4433 – Parviz Oct 12 '16 at 18:17
• Could you elaborate on your data? What's the Mathematica expression of your data? The way you type it out here is not clear at all to me and I don't know what you'd need to do to get it in the right shape. Does it look like this: {1, 26.8283, 48.4646, 2, 26.4985, 48.7885, ....}? And are the integers 1, 2, 3 actual data points or do they just number the {x, y}-pairs? – Sjoerd Smit Oct 13 '16 at 8:59
• I tried several times for inserting my data but it does not show up correctly. my data look like 1 26.8283 48.4646 (enter) – Parviz Oct 13 '16 at 14:39
• I tried several times for inserting my data but it does not show up correctly. my data look like 1 26.8283 48.4646 (enter) 2 26.4985 48.7885 (enter) .... three columns first column is the integer (number of time step) second and third are the number between 8 and 50. – Parviz Oct 13 '16 at 14:43