# pass fail criteria as legend in histogram and plot

I have a random data and want to plot the histogram with specific bin ranges. Each value of data[[x]] is actually [(data[[x]]*2.2)/4] with units as microns; where 4 is the magnification of microscope objective and 2.2 (microns) is the pixel pitch of the imaging sensor. How is it possible to show how many/ how much % lie exactly at 15 microns and 15 +/-1 micron. Just like a tolerance range.

*So if it has to be 15 microns, then (15*4)/2.2 should be the threshold value for that in data[].*

data=RandomChoice[{32,38},1632]
ListLinePlot[data, PlotStyle-> Thick, PlotTheme -> "Detailed", Filling -> Bottom, AspectRatio->1/4]
(*each pixel would appear to be 8.8 since its magnified by 4, hence 8.8 would be the step *)
Histogram[data,{25.454,29.090,8.8},"Count", PlotTheme-> Detailed, LabellingFunction -> Above]


I am trying to get a legend displayed on the histogram or plot that says this much is within range, Is this approach correct ?

I am not quite sure that understood you. Your data, for example, only contains the figures 32 and 38 taken in a random order. Here are 10 of them:

    data = RandomChoice[{32, 38}, 10]

(*  {32, 32, 32, 38, 32, 32, 38, 38, 32, 38}  *)


According to the description your microscopic data should be more close to the following (again there are only 25 figures for the purpose of viewing):

 data = RandomInteger[{10, 38}, 25]

(*  {21, 10, 11, 30, 29, 18, 16, 19, 15, 10, 22, 17, 13, 15, 35, 12, 30, \
33, 17, 32, 36, 19, 25, 17, 28}   *)


If I am right, it is easy to count the number of terms with certain values. Just 14 microns should give you

 14*4/2.2

(*  25.4545   *)


15 microns give

    15*4/2.2
(* 27.2727  *)


and 16 microns yield

    16*4/2.2

(*   29.0909  *)


Now to find out how much are there the elements in the list

 data = RandomInteger[{10, 38}, 1632];


between 14 and 16 microns let us do the following. First find the list of terms lying within this interval:

lst = Select[data, 25.5 <= # <= 29.1 &];


then calculate its length and the length og the initial list, and find their ratio:

     Length[lst]/Length[data]*100.*percents
(*   14.6446 percents   *)


If you want a histogram, do it:

Histogram[data, {1}]


returning this: The {1} argument controls the bin width.

Have fun!

• I used the data to calculate the percentage and control the bin range to show. Jun 24, 2015 at 17:48