- /* Put the y axis on */
- for ( d = y_min; d <= y_max ; d += y_tick )
- {
- draw_tick (ch, TICK_ORDINATE, (d - y_min ) * ordinate_scale, "%g", d);
- }
+ if ( show_normal )
+ {
+ /* Draw the normal curve */
+
+ double d ;
+ double x_min, x_max, not_used ;
+ double abscissa_scale ;
+ double ordinate_scale ;
+ double range ;
+
+ gsl_histogram_get_range(hist, 0, &x_min, ¬_used);
+ range = not_used - x_min;
+ gsl_histogram_get_range(hist, bins - 1, ¬_used, &x_max);
+ assert(range == x_max - not_used);
+
+ abscissa_scale = (ch.data_right - ch.data_left) / (x_max - x_min);
+ ordinate_scale = (ch.data_top - ch.data_bottom) /
+ gsl_histogram_max_val(hist) ;
+
+ pl_move_r(ch.lp, ch.data_left, ch.data_bottom);
+ for( d = ch.data_left;
+ d <= ch.data_right ;
+ d += (ch.data_right - ch.data_left) / 100.0)
+ {
+ const double x = (d - ch.data_left) / abscissa_scale + x_min ;
+ const double y = norm->N * range *
+ gsl_ran_gaussian_pdf(x - norm->mean, norm->stddev);
+
+ pl_fcont_r(ch.lp, d, ch.data_bottom + y * ordinate_scale);