- if (num_leg > 0 && ez.o_legendbox != NOLEGEND) {
- leg_width = (max_leg + 2) * charwidth;
- leg_height = num_leg * 3 * charheight;
-
- if (ez.s_xlegend == TRUE)
- xl_max = ez.v_xlegend;
- else {
- xl_max = xa_max;
- if (ez.o_legendbox == OUTSIDE)
- xa_max -= (leg_width + 0.5 * charwidth);
- }
- xl_min = xl_max - leg_width;
-
- if (ez.s_ylegend == TRUE)
- yl_max = ez.v_ylegend;
- else
- yl_max = ya_max;
-
- yl_min = yl_max - leg_height;
-
- sgp2_window (xl_min, yl_min, xl_max, yl_max);
- sgp2_viewport (xl_min, yl_min, xl_max, yl_max);
-
- sgp2_color (ez.clr_legend);
- sgp2_draw_rect (xl_min, yl_min, xl_max, yl_max);
-
- n = 0; /* current legend position */
- for (i = 0; i < ez.i_numcurves; i++) {
- double xmin, xmax, xinc, y;
-
- if (strlen(ez.curve[i].legend) == 0)
- continue;
-
- xmin = xl_min + 1.0 * charwidth;
- xmax = xl_max - 1.0 * charwidth;
- y = yl_max - (2.0 + n * 3) * charheight;
-
- sgp2_move_abs (xmin, y + 0.5 * charheight);
- sgp2_draw_text (ez.curve[i].legend);
- sgp2_color (ez.curve[i].color);
- if (ez.curve[i].linestyle != LS_NOLINE) {
- sgp2_line_style (ez.curve[i].linestyle);
- sgp2_move_abs (xmin, y);
- sgp2_line_abs (xmax, y);
- }
- if (ez.curve[i].symbol > 0) {
- xinc = (xmax - xmin) / (5 - 1);
- sgp2_line_style (LS_SOLID);
- for (j = 0; j < 5; j++) {
- sgp2_move_abs (xmin + j * xinc, y);
- symbol(ez.curve[i].symbol,
- 0.5 * charwidth, 0.5 * charheight);
- }
- }
- ++n; /* move to next legend position */
- }
- } /* end legend printing */
-
- /* calculate the extent of the axes */
-
- /*-------------------------*/
- /* adjust frame for labels */
- /*-------------------------*/
-
- /* x-label */
-
- if (strlen(ez.c_xlabel) > 0)
- ya_min += 3.0 * charheight;
- xlbl_row = xp_min; /* put x-label on bottom of plot frame */
-
- /* y-label */
-
- if (strlen(ez.c_ylabel) > 0)
- xa_min += 3.0 * charwidth; /* reverse charsize because writing */
- /* text sideways */
- ylbl_col = xp_min + 2 * charwidth;
-
- /*------------------------------*/
- /* adjust frame for tick labels */
- /*------------------------------*/