/[pspp]/pspp/src/plot-hist.c
ViewVC logotype

Diff of /pspp/src/plot-hist.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jmd, Fri Jan 7 00:17:20 2005 UTC revision 1.2 by jmd, Fri Jan 14 04:05:47 2005 UTC
# Line 17  Line 17 
17     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18     02111-1307, USA. */     02111-1307, USA. */
19    
20    /* If you add/modify any public symbols in this file, don't forget to
21       change the stubs in dummy-chart.c */
22    
23  #include <config.h>  #include <config.h>
24    
25  #include <stdio.h>  #include <stdio.h>
# Line 107  histogram_plot(const gsl_histogram *hist Line 110  histogram_plot(const gsl_histogram *hist
110    int i;    int i;
111    int bins;    int bins;
112        
113    struct chart ch;    struct chart *ch;
114    
115    bins = gsl_histogram_bins(hist);    bins = gsl_histogram_bins(hist);
116    
117    chart_initialise(&ch);    ch = chart_create();
118    chart_write_title(&ch, _("HISTOGRAM"));    chart_write_title(ch, _("HISTOGRAM"));
119    
120    chart_write_ylabel(&ch, _("Frequency"));    chart_write_ylabel(ch, _("Frequency"));
121    chart_write_xlabel(&ch, factorname);    chart_write_xlabel(ch, factorname);
122    
123    chart_write_yscale(&ch, 0, gsl_histogram_max_val(hist), 5);    chart_write_yscale(ch, 0, gsl_histogram_max_val(hist), 5);
124    
125    for ( i = 0 ; i < bins ; ++i )    for ( i = 0 ; i < bins ; ++i )
126        hist_draw_bar(&ch, hist, i);        hist_draw_bar(ch, hist, i);
127    
128    histogram_write_legend(&ch, norm);    histogram_write_legend(ch, norm);
129    
130    if ( show_normal  )    if ( show_normal  )
131    {    {
# Line 139  histogram_plot(const gsl_histogram *hist Line 142  histogram_plot(const gsl_histogram *hist
142      gsl_histogram_get_range(hist, bins - 1, &not_used, &x_max);      gsl_histogram_get_range(hist, bins - 1, &not_used, &x_max);
143      assert(range == x_max - not_used);      assert(range == x_max - not_used);
144    
145      abscissa_scale = (ch.data_right - ch.data_left) / (x_max - x_min);      abscissa_scale = (ch->data_right - ch->data_left) / (x_max - x_min);
146      ordinate_scale = (ch.data_top - ch.data_bottom) /      ordinate_scale = (ch->data_top - ch->data_bottom) /
147        gsl_histogram_max_val(hist) ;        gsl_histogram_max_val(hist) ;
148    
149      pl_move_r(ch.lp, ch.data_left, ch.data_bottom);          pl_move_r(ch->lp, ch->data_left, ch->data_bottom);    
150      for( d = ch.data_left;      for( d = ch->data_left;
151           d <= ch.data_right ;           d <= ch->data_right ;
152           d += (ch.data_right - ch.data_left) / 100.0)           d += (ch->data_right - ch->data_left) / 100.0)
153        {            {    
154          const double x = (d - ch.data_left) / abscissa_scale + x_min ;          const double x = (d - ch->data_left) / abscissa_scale + x_min ;
155          const double y = norm->N * range *          const double y = norm->N * range *
156            gsl_ran_gaussian_pdf(x - norm->mean, norm->stddev);            gsl_ran_gaussian_pdf(x - norm->mean, norm->stddev);
157    
158          pl_fcont_r(ch.lp,  d,  ch.data_bottom  + y * ordinate_scale);          pl_fcont_r(ch->lp,  d,  ch->data_bottom  + y * ordinate_scale);
159    
160        }        }
161      pl_endpath_r(ch.lp);      pl_endpath_r(ch->lp);
162    
163    }    }
164    chart_finalise(&ch);    chart_submit(ch);
165  }  }
166    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26