1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "output/charts/scree.h"
23 #include "output/cairo-chart.h"
26 #define _(msgid) gettext (msgid)
29 xrchart_draw_scree (const struct chart_item *chart_item, cairo_t *cr,
30 struct xrchart_geometry *geom)
32 const struct scree *rc = to_scree (chart_item);
36 xrchart_write_title (cr, geom, _("Scree Plot"));
37 xrchart_write_xlabel (cr, geom, rc->xlabel);
38 xrchart_write_ylabel (cr, geom, _("Eigenvalue"));
40 gsl_vector_minmax (rc->eval, &min, &max);
42 if ( fabs (max) > fabs (min))
47 xrchart_write_yscale (cr, geom, 0, max);
48 xrchart_write_xscale (cr, geom, 0, rc->eval->size + 1);
50 xrchart_vector_start (cr, geom, "");
51 for (i = 0 ; i < rc->eval->size; ++i)
53 const double x = 1 + i;
54 const double y = gsl_vector_get (rc->eval, i);
55 xrchart_vector (cr, geom, x, y);
57 xrchart_vector_end (cr, geom);
59 for (i = 0 ; i < rc->eval->size; ++i)
61 const double x = 1 + i;
62 const double y = gsl_vector_get (rc->eval, i);
63 xrchart_datum (cr, geom, 0, x, y);