-
-
-void
-histogram_plot (const struct histogram *hist,
- const char *label,
- const struct moments1 *m)
-{
- double mean, var, n;
-
- moments1_calculate (m, &n, &mean, &var, NULL, NULL);
-
- histogram_plot_n (hist, label, n, mean, sqrt(var), m);
-}
-
-
-/* This function is deprecated. Don't use it in new code */
-void
-histogram_plot_n (const struct histogram *hist,
- const char *label,
- double n, double mean, double stddev,
- bool show_normal)
-{
- int i;
- int bins;
-
- struct chart *ch = chart_create ();
-
- chart_write_title (ch, _("HISTOGRAM"));
-
- chart_write_ylabel (ch, _("Frequency"));
- chart_write_xlabel (ch, label);
-
- if ( ! hist ) /* If this happens, probably all values are SYSMIS */
- {
- chart_submit (ch);
- return;
- }
- else
- {
- bins = gsl_histogram_bins (hist->gsl_hist);
- }
-
- chart_write_yscale (ch, 0, gsl_histogram_max_val (hist->gsl_hist), 5);
-
- for ( i = 0 ; i < bins ; ++i )
- hist_draw_bar (ch, hist, i);
-
- histogram_write_legend (ch, n, mean, stddev);
-
- 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->gsl_hist, 0, &x_min, ¬_used);
- range = not_used - x_min;
- gsl_histogram_get_range (hist->gsl_hist, bins - 1, ¬_used, &x_max);
-
- 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->gsl_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 = n * range *
- gsl_ran_gaussian_pdf (x - mean, stddev);
-
- pl_fcont_r (ch->lp, d, ch->data_bottom + y * ordinate_scale);
-
- }
- pl_endpath_r (ch->lp);
- }
-
- chart_submit (ch);
-}
-
-