title: Figuring out where to add text in a MATLAB histogram
body: <p>I have a MATLAB histogram graph produced with some data, with some 50 bins. I now need to insert a line of text into the graph, at any place where it wouldn't tangle with the histogram bars. The text is basically 'Period of data used: mmm dd to mmm dd' (I mention this to give an idea of the width required and where the text can be split if necessary).</p>
  
  <p>One method I considered was finding out a series of contiguous histogram bins where the freq (y axis) remains less than 90% of the maximum of all frequencies; then, the text can be printed at the x position starting at the first of those bins near the top of the graph. </p>
  
  <p>Is this a good way of going about it? If so, how do I compute this contiguous series of bins without looping around? </p>
  
  <p>Or is there a better way of placing this text adaptively according to the data? </p>
  
  <p>Edit: Due to other considerations, the number of histogram bins is not a fixed 50 any more, but rather <code>xmax/20</code> where xmax is the maximum x-axis value. Algorithms that depend on working on aggregates of a number of bins might need to take this variability into account, when calculating that number. </p>