-static
-double get_slack (double limit, double half_bin_width, int *n_half_bins)
-{
- double ipart, remainder;
-
- assert (half_bin_width > 0);
-
- remainder = modf (limit / half_bin_width, &ipart);
-
- /* In C modf and % behave in an unexpected (to me at any rate) manner
- when presented with a negative value
-
- For example, modf (-7.0 / 3.0) returns -2.0 R -0.3333
- */
-
-
- *n_half_bins = ipart;
-
- return remainder * half_bin_width;
-}
-
-
-/* This functions adjusts the upper and lower range of the histogram to make them fit BIN_WIDTH
- MIN and MAX are the lowest and highest data to be plotted in the histogram.
- ADJ_MIN and ADJ_MAX are locations of the adjusted values of MIN and MAX (the range will
- always be equal or slightly larger).
- Returns the number of bins.
-
- The "testing_assert" expressions in this function should be algebraically correct.
- However, due to floating point rounding they could fail, especially when small numbers
- are involved. In normal use, therefore, testing_assert does nothing.
- */
+/* Find a bin width which is adapted to the scaling of the x axis
+In the example here, the binwidth is half of the tick interval.
+
+ binwidth
+ > <
+ |....+....+....+. .+....|
+ LOWER 1 2 3 N_TICKS
+ ^LOWDBL ^HIGHDBL
+
+This only works, when the min and max value for the histogram are adapted
+such that (max-min) is a multiple of the binwidth. Then the location of the
+first bin has to be aligned to the ticks.
+*/