49 if ( plsc->level < 1 )
51 plabort(
"plgvpsp: Please call plinit first" );
54 if ( ( plsc->cursub <= 0 ) || ( plsc->cursub > ( plsc->nsubx * plsc->nsuby ) ) )
56 plabort(
"plgvpsp: Please call pladv or plenv to go to a subpage" );
59 *p_xmin = ( plsc->vpdxmi - plsc->spdxmi ) / ( plsc->spdxma - plsc->spdxmi );
60 *p_xmax = ( plsc->vpdxma - plsc->spdxmi ) / ( plsc->spdxma - plsc->spdxmi );
61 *p_ymin = ( plsc->vpdymi - plsc->spdymi ) / ( plsc->spdyma - plsc->spdymi );
62 *p_ymax = ( plsc->vpdyma - plsc->spdymi ) / ( plsc->spdyma - plsc->spdymi );
89 PLFLT *x_legend_position,
PLFLT *y_legend_position,
102 PLFLT xorigin = 0.0, yorigin = 0.0, xlegend = 0.0, ylegend = 0.0;
114 xlegend = -legend_width;
122 ylegend = legend_height;
126 plexit(
"legend_position: internal logic error 1" );
132 ylegend = 0.5 * legend_height;
135 xlegend = -legend_width;
144 plexit(
"legend_position: internal logic error 2" );
147 else if ( position & PL_POSITION_BOTTOM )
152 xlegend = -legend_width;
153 ylegend = legend_height;
164 plexit(
"legend_position: internal logic error 3" );
169 plexit(
"legend_position: internal logic error 4" );
172 else if ( !( position & PL_POSITION_RIGHT ) && !( position &
PL_POSITION_LEFT ) )
175 xlegend = -0.5 * legend_width;
186 ylegend = legend_height;
190 plexit(
"legend_position: internal logic error 5" );
198 ylegend = legend_height;
207 plexit(
"legend_position: internal logic error 6" );
212 plexit(
"legend_position: internal logic error 7" );
215 else if ( position & PL_POSITION_LEFT )
229 xlegend = -legend_width;
230 ylegend = legend_height;
235 plexit(
"legend_position: internal logic error 8" );
241 ylegend = 0.5 * legend_height;
248 xlegend = -legend_width;
253 plexit(
"legend_position: internal logic error 9" );
256 else if ( position & PL_POSITION_BOTTOM )
261 ylegend = legend_height;
266 xlegend = -legend_width;
273 plexit(
"legend_position: internal logic error 10" );
278 plexit(
"legend_position: internal logic error 11" );
283 plexit(
"legend_position: internal logic error 12" );
285 *x_legend_position = xorigin + xlegend;
286 *y_legend_position = yorigin + ylegend;
299 PLFLT mxmin, mxmax, mymin, mymax;
300 plgspa( &mxmin, &mxmax, &mymin, &mymax );
301 *x_subpage_per_mm = 1. / ( mxmax - mxmin );
302 *y_subpage_per_mm = 1. / ( mymax - mymin );
316 PLFLT default_mm, char_height_mm;
317 PLFLT x_subpage_per_mm, y_subpage_per_mm;
321 plgchr( &default_mm, &char_height_mm );
325 default_mm = plsc->symdef;
326 char_height_mm = plsc->symht;
329 return ( char_height_mm * y_subpage_per_mm );
345 #define adopted_to_subpage_x( nx ) ( ( xdmin_adopted ) + ( nx ) * ( ( xdmax_adopted ) - ( xdmin_adopted ) ) )
360 #define subpage_to_adopted_x( nx ) ( ( nx - xdmin_adopted ) / ( ( xdmax_adopted ) - ( xdmin_adopted ) ) )
375 #define adopted_to_subpage_y( ny ) ( ( ydmin_adopted ) + ( ny ) * ( ( ydmax_adopted ) - ( ydmin_adopted ) ) )
390 #define subpage_to_adopted_y( ny ) ( ( ny - ydmin_adopted ) / ( ( ydmax_adopted ) - ( ydmin_adopted ) ) )
538 PLFLT text_justification,
539 const PLINT *text_colors,
const char *
const *
text,
540 const PLINT *box_colors,
const PLINT *box_patterns,
541 const PLFLT *box_scales,
const PLFLT *box_line_widths,
542 const PLINT *line_colors,
const PLINT *line_styles,
543 const PLFLT *line_widths,
544 const PLINT *symbol_colors,
const PLFLT *symbol_scales,
545 const PLINT *symbol_numbers,
const char *
const *symbols )
549 PLFLT plot_x, plot_x_end, plot_x_subpage, plot_x_end_subpage;
550 PLFLT plot_y, plot_y_subpage;
551 PLFLT text_x, text_y, text_x_subpage, text_y_subpage;
553 PLFLT character_height, character_width, symbol_width = 0.0;
555 PLFLT ty, xshift, drow, dcolumn;
557 PLFLT dxs, *xs = NULL, *ys = NULL,
xl[2],
yl[2], xbox[4], ybox[4];
560 PLINT col0_save = plsc->icol0,
561 line_style_save = plsc->line_style,
562 pattern_save = plsc->patt;
563 PLFLT line_width_save = plsc->width;
564 PLFLT text_scale_save = plsc->chrht / plsc->chrdef;
566 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
569 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
572 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
574 PLFLT x_subpage_per_mm, y_subpage_per_mm, text_width0 = 0., text_width;
575 PLFLT width_border, column_separation,
576 legend_width, legend_height, legend_width_ac, legend_height_ac;
577 PLFLT x_legend_position, y_legend_position, xsign, ysign;
579 PLINT some_symbols = 0;
580 PLINT max_symbol_numbers = 0;
581 PLINT irow = 0, icolumn = 0;
582 int some_boxes = 0, some_lines = 0;
585 nrow =
MAX( nrow, 1 );
586 ncolumn =
MAX( ncolumn, 1 );
587 if ( nrow * ncolumn < nlegend )
590 if ( ncolumn < nrow )
591 ncolumn = ( nlegend % nrow ) ? ( nlegend / nrow ) + 1 : nlegend / nrow;
593 nrow = ( nlegend % ncolumn ) ? ( nlegend / ncolumn ) + 1 : nlegend / ncolumn;
602 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
604 plabort(
"pllegend: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
610 plabort(
"pllegend: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
618 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
620 plabort(
"pllegend: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
628 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
630 plabort(
"pllegend: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
637 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
640 if ( position & PL_POSITION_SUBPAGE )
650 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
654 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
664 for ( i = 0; i < nlegend; i++ )
672 if ( symbol_numbers != NULL )
673 max_symbol_numbers =
MAX( max_symbol_numbers, symbol_numbers[i] );
679 if ( some_boxes && ( box_colors == NULL || box_patterns == NULL || box_scales == NULL || box_line_widths == NULL ) )
681 plabort(
"pllegend: all box_* arrays must be defined when the PL_LEGEND_COLOR_BOX bit is set." );
685 if ( some_lines && ( line_colors == NULL || line_styles == NULL || line_widths == NULL ) )
687 plabort(
"pllegend: all line_* arrays must be defined when the PL_LEGEND_LINE bit is set." );
691 if ( some_symbols && ( symbol_colors == NULL || symbol_scales == NULL || symbol_numbers == NULL ) )
693 plabort(
"pllegend: all symbol_* arrays must be defined when the PL_LEGEND_SYMBOL bit is set." );
699 character_width = character_height;
703 for ( i = 0; i < nlegend; i++ )
706 text_width0 =
MAX( text_width0,
plstrl( text[i] ) );
711 text_width0 = x_subpage_per_mm * text_width0;
714 text_width = text_width0 + text_offset * character_width;
719 width_border = 0.4 * character_width;
721 column_separation = 2.0 * character_width;
724 legend_width = 2. * width_border + ( ncolumn - 1 ) * column_separation +
725 ncolumn * ( text_width +
727 legend_height = nrow * text_spacing * character_height;
733 *p_legend_width = legend_width_ac;
734 *p_legend_height = legend_height_ac;
738 dcolumn = column_separation + text_width +
740 drow = text_spacing * character_height;
742 legend_position( position, legend_width_ac, legend_height_ac, &x_legend_position, &y_legend_position, &xsign, &ysign );
743 plot_x = x * xsign + x_legend_position;
744 plot_y = y * ysign + y_legend_position;
745 plot_x_end = plot_x + plot_width;
755 text_offset * character_width;
763 plot_x_subpage + legend_width,
764 plot_x_subpage + legend_width,
768 plot_y_subpage - legend_height,
769 plot_y_subpage - legend_height,
783 plot_x_subpage + legend_width,
784 plot_x_subpage + legend_width,
789 plot_y_subpage - legend_height,
790 plot_y_subpage - legend_height,
798 pllsty( line_style_save );
804 text_x_subpage = plot_x_subpage;
805 plot_x_subpage += text_width;
806 plot_x_end_subpage += text_width;
809 plot_x_subpage += width_border;
810 plot_x_end_subpage += width_border;
811 text_x_subpage += width_border;
815 max_symbol_numbers =
MAX( 2, max_symbol_numbers );
816 if ( ( ( xs = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) ||
817 ( ( ys = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) )
819 plexit(
"pllegend: Insufficient memory" );
831 for ( i = 0; i < nlegend; i++ )
834 ty = text_y_subpage - ( (double) irow + 0.5 ) * drow;
835 xshift = (double) icolumn * dcolumn;
839 plptex( text_x_subpage + xshift + text_justification * text_width0, ty, 0.1, 0.0, text_justification, text[i] );
846 plpsty( box_patterns[i] );
848 xbox[0] = plot_x_subpage + xshift;
850 xbox[2] = plot_x_end_subpage + xshift;
852 ybox[0] = ty + 0.5 * drow * box_scales[i];
853 ybox[1] = ty - 0.5 * drow * box_scales[i];
854 ybox[2] = ty - 0.5 * drow * box_scales[i];
855 ybox[3] = ty + 0.5 * drow * box_scales[i];
857 pllsty( line_style_save );
865 xl[0] = plot_x_subpage + xshift;
866 xl[1] = plot_x_end_subpage + xshift;
870 pllsty( line_style_save );
876 plcol0( symbol_colors[i] );
877 plschr( 0., symbol_scales[i] );
878 dxs = ( plot_x_end_subpage - plot_x_subpage - symbol_width ) / (
double) (
MAX( symbol_numbers[i], 2 ) - 1 );
879 for ( j = 0; j < symbol_numbers[i]; j++ )
881 xs[j] = plot_x_subpage + xshift +
882 0.5 * symbol_width + dxs * (double) j;
885 plstring( symbol_numbers[i], xs, ys, symbols[i] );
893 if ( icolumn >= ncolumn )
917 plschr( 0., text_scale_save );
919 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
920 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );
938 for ( src = dst =
string; *src !=
'\0'; src++ )
941 while ( ( *ptr !=
'\0' ) && ( *src != *ptr ) )
978 PLINT col0_save = plsc->icol0;
1026 plexit(
"draw_cap: internal error. Incorrect orientation" );
1067 const char *edge_string;
1068 size_t length_axis_opts = strlen( axis_opts );
1069 char *local_axis_opts;
1073 if ( ( local_axis_opts = (
char *) malloc( ( length_axis_opts + 1 ) *
sizeof (
char ) ) ) == NULL )
1075 plexit(
"draw_box: Insufficient memory" );
1077 strcpy( local_axis_opts, axis_opts );
1079 plsc->if_boxbb = if_bb;
1093 plsc->if_boxbb =
FALSE;
1094 free( local_axis_opts );
1110 plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks );
1114 plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 );
1116 plsc->if_boxbb =
FALSE;
1118 free( local_axis_opts );
1146 PLFLT label_offset = 1.2;
1172 PLFLT parallel_height_mm = 0.0, perpendicular_height_mm = 0.0,
1173 default_mm, char_height_mm;
1184 opt = opt & ~PL_COLORBAR_LABEL_TOP;
1191 opt = opt & ~PL_COLORBAR_LABEL_LEFT;
1198 opt = opt & ~PL_COLORBAR_LABEL_BOTTOM;
1206 plgchr( &default_mm, &char_height_mm );
1215 plsc->boxbb_xmin = plsc->vppxmi / plsc->xpmm;
1216 plsc->boxbb_xmax = plsc->vppxma / plsc->xpmm;
1217 plsc->boxbb_ymin = plsc->vppymi / plsc->ypmm;
1218 plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm;
1225 parallel_height_mm = ( label_offset + 0.8 ) * char_height_mm;
1232 perpendicular_height_mm = ( label_offset - 0.5 + 0.0 ) * char_height_mm;
1234 if ( opt & PL_COLORBAR_LABEL_LEFT )
1242 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1243 plsc->xpmm - parallel_height_mm );
1244 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1245 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1246 plsc->ypmm - 0.5 * label_length_mm );
1247 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1248 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1249 plsc->ypmm + 0.5 * label_length_mm );
1256 label_offset -= 0.5;
1259 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1260 plsc->xpmm - perpendicular_height_mm - label_length_mm );
1265 else if ( opt & PL_COLORBAR_LABEL_RIGHT )
1273 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1274 plsc->xpmm + parallel_height_mm );
1275 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1276 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1277 plsc->ypmm - 0.5 * label_length_mm );
1278 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1279 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1280 plsc->ypmm + 0.5 * label_length_mm );
1287 label_offset -= 0.5;
1290 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1291 plsc->xpmm + perpendicular_height_mm + label_length_mm );
1296 else if ( opt & PL_COLORBAR_LABEL_TOP )
1303 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, plsc->vppyma /
1304 plsc->ypmm + parallel_height_mm );
1305 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1306 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1307 plsc->xpmm - 0.5 * label_length_mm );
1308 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1309 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1310 plsc->xpmm + 0.5 * label_length_mm );
1313 else if ( opt & PL_COLORBAR_LABEL_BOTTOM )
1320 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, plsc->vppymi /
1321 plsc->ypmm - parallel_height_mm );
1322 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1323 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1324 plsc->xpmm - 0.5 * label_length_mm );
1325 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1326 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1327 plsc->xpmm + 0.5 * label_length_mm );
1331 plmtex( opt_label, label_offset, 0.5, just, label );
1351 PLFLT prior_bb_height,
1352 PLFLT *p_colorbar_width_bb,
PLFLT *p_colorbar_height_bb,
1353 PLFLT *p_colorbar_width_ac,
PLFLT *p_colorbar_height_ac,
1354 PLFLT *p_plot_x_subpage_bb,
PLFLT *p_plot_y_subpage_bb,
1358 PLFLT x_colorbar_position, y_colorbar_position, xsign, ysign;
1359 PLFLT plot_x, plot_y;
1362 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1363 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1366 *p_colorbar_width_bb = ( plsc->boxbb_xmax - plsc->boxbb_xmin ) * spxpmm;
1367 *p_colorbar_height_bb = ( plsc->boxbb_ymax - plsc->boxbb_ymin ) * spypmm;
1373 *p_dx_subpage = -plsc->boxbb_xmin * spxpmm;
1374 *p_dy_subpage = prior_bb_height - plsc->boxbb_ymax * spypmm;
1386 legend_position( position, *p_colorbar_width_ac, *p_colorbar_height_ac, &x_colorbar_position, &y_colorbar_position, &xsign, &ysign );
1387 plot_x = x * xsign + x_colorbar_position;
1388 plot_y = y * ysign + y_colorbar_position;
1544 PLFLT min_value = 0., max_value = 0., max_abs = 0.;
1547 PLFLT cap_extent, cap_extent_mm;
1554 PLFLT cap_angle = 45.;
1559 PLFLT cap_ratio = 0.5 / tan(
PI / 360. * cap_angle );
1562 PLFLT aspspp = ( ( plsc->sppxma - plsc->sppxmi ) / plsc->xpmm ) /
1563 ( ( plsc->sppyma - plsc->sppymi ) / plsc->ypmm );
1566 PLFLT min_color, max_color;
1569 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
1572 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
1576 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
1579 PLINT col0_save = plsc->icol0,
1580 line_style_save = plsc->line_style;
1583 PLFLT plot_x_subpage_bb, plot_y_subpage_bb;
1590 PLFLT colorbar_width, colorbar_height,
1591 colorbar_width_d, colorbar_height_d,
1592 colorbar_width_l, colorbar_height_l;
1598 PLFLT colorbar_width_ac, colorbar_height_ac,
1599 colorbar_width_mm, colorbar_height_mm;
1605 PLFLT dx_subpage_omd, dy_subpage_omd, dx_subpage_dml, dy_subpage_dml;
1606 PLFLT dx_subpage_omd_accu = 0.0, dy_subpage_omd_accu = 0.0, dx_subpage_dml_accu = 0.0, dy_subpage_dml_accu = 0.0;
1609 PLFLT plot_x_subpage, plot_y_subpage;
1612 PLFLT vx_min = 0.0, vx_max = 0.0, vy_min = 0.0, vy_max = 0.0;
1615 PLFLT wx_min = 0.0, wx_max = 0.0, wy_min = 0.0, wy_max = 0.0;
1621 PLINT i, j, ni = 0, nj = 0, n_steps;
1625 PLBOOL if_edge_b = 0, if_edge_c = 0, if_edge_u = 0, if_edge_w = 0;
1629 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1630 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1633 PLFLT label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax;
1640 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
1642 plabort(
"plcolorbar: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
1648 plabort(
"plcolorbar: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
1656 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
1658 plabort(
"plcolorbar: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
1666 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
1668 plabort(
"plcolorbar: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
1673 if ( n_labels > 0 && ( label_opts == NULL || labels == NULL ) )
1675 plabort(
"plcolorbar: label_opts and labels arrays must be defined when n_labels > 0." );
1681 plabort(
"plcolorbar: At least one axis must be specified" );
1688 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
1691 if ( position & PL_POSITION_SUBPAGE )
1692 plvpor( 0., 1., 0., 1. );
1701 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
1705 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
1719 for ( i = 0; i < n_axes; i++ )
1721 if_edge_b = if_edge_b ||
plP_stsearch( axis_opts[i],
'b' );
1722 if_edge_c = if_edge_c ||
plP_stsearch( axis_opts[i],
'c' );
1723 if_edge_u = if_edge_u ||
plP_stsearch( axis_opts[i],
'u' );
1724 if_edge_w = if_edge_w ||
plP_stsearch( axis_opts[i],
'w' );
1726 if_edge = if_edge_b && if_edge_c && !( if_edge_u || if_edge_w );
1737 colorbar_width_d = colorbar_width;
1738 colorbar_height_d = colorbar_height;
1739 colorbar_width_mm = colorbar_width / spxpmm;
1740 colorbar_height_mm = colorbar_height / spypmm;
1745 cap_extent = cap_ratio * colorbar_height / aspspp;
1746 cap_extent_mm = cap_extent / spxpmm;
1750 cap_extent = cap_ratio * colorbar_width * aspspp;
1751 cap_extent_mm = cap_extent / spypmm;
1754 for ( i = n_axes - 1; i >= 0; i-- )
1756 min_value = values[i][0];
1757 max_value = values[i][ n_values[i] - 1 ];
1758 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
1776 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1783 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1792 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1799 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1800 plwind( wx_min, wx_max, wy_min, wy_max );
1805 ticks[i], sub_ticks[i], n_values[i], values[i] );
1807 if ( i == n_axes - 1 )
1811 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1812 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1813 if ( opt & PL_COLORBAR_ORIENT_TOP )
1814 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1815 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1816 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1817 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1818 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1822 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1823 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1824 if ( opt & PL_COLORBAR_ORIENT_TOP )
1825 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1826 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1827 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1828 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1829 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1835 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1837 &colorbar_width_d, &colorbar_height_d,
1838 &colorbar_width_ac, &colorbar_height_ac,
1839 &plot_x_subpage_bb, &plot_y_subpage_bb,
1840 &dx_subpage_omd, &dy_subpage_omd );
1845 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1847 dx_subpage_omd_accu += dx_subpage_omd;
1848 dy_subpage_omd_accu += dy_subpage_omd;
1852 colorbar_width_l = colorbar_width_d;
1853 colorbar_height_l = colorbar_height_d;
1861 plvpor( 0., colorbar_width_l, 0., colorbar_height_l );
1862 plwind( wx_min, wx_max, wy_min, wy_max );
1869 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1871 &colorbar_width_l, &colorbar_height_l,
1872 &colorbar_width_ac, &colorbar_height_ac,
1873 &plot_x_subpage_bb, &plot_y_subpage_bb,
1874 &dx_subpage_dml, &dy_subpage_dml );
1876 dx_subpage_dml_accu += dx_subpage_dml;
1877 dy_subpage_dml_accu += dy_subpage_dml;
1882 plot_x_subpage = plot_x_subpage_bb + dx_subpage_omd_accu + dx_subpage_dml_accu;
1883 plot_y_subpage = plot_y_subpage_bb + dy_subpage_omd_accu + dy_subpage_dml_accu;
1886 label_vpor_xmin = plot_x_subpage_bb + dx_subpage_dml_accu;
1887 label_vpor_xmax = label_vpor_xmin + colorbar_width_d;
1888 label_vpor_ymax = plot_y_subpage_bb + dy_subpage_dml_accu;
1889 label_vpor_ymin = label_vpor_ymax - colorbar_height_d;
1893 *p_colorbar_width = colorbar_width_ac;
1894 *p_colorbar_height = colorbar_height_ac;
1900 vx_min = plot_x_subpage;
1901 vx_max = plot_x_subpage + colorbar_width;
1902 vy_min = plot_y_subpage - colorbar_height;
1903 vy_max = plot_y_subpage;
1907 vx_min = plot_x_subpage;
1908 vx_max = plot_x_subpage + colorbar_width;
1909 vy_min = plot_y_subpage - colorbar_height;
1910 vy_max = plot_y_subpage;
1912 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1914 vx_min = plot_x_subpage;
1915 vx_max = plot_x_subpage + colorbar_width;
1916 vy_min = plot_y_subpage - colorbar_height;
1917 vy_max = plot_y_subpage;
1919 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1921 vx_min = plot_x_subpage;
1922 vx_max = plot_x_subpage + colorbar_width;
1923 vy_min = plot_y_subpage - colorbar_height;
1924 vy_max = plot_y_subpage;
1928 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1932 plvpor( 0., 1., 0., 1. );
1933 plwind( 0., 1., 0., 1. );
1940 plot_x_subpage_bb + colorbar_width_l,
1941 plot_x_subpage_bb + colorbar_width_l,
1945 plot_y_subpage_bb - colorbar_height_l,
1946 plot_y_subpage_bb - colorbar_height_l,
1956 plvpor( vx_min, vx_max, vy_min, vy_max );
1957 plwind( wx_min, wx_max, wy_min, wy_max );
1965 if ( n_values[0] == 2 )
1970 n_steps = plsc->ncol1;
1971 step_size = ( max_value - min_value ) / (
PLFLT) n_steps;
1972 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1977 for ( i = 0; i < ni; i++ )
1979 for ( j = 0; j < nj; j++ )
1981 color_data[i][j] = min_value + (
PLFLT) i * step_size;
1985 else if ( opt & PL_COLORBAR_ORIENT_TOP )
1990 for ( i = 0; i < ni; i++ )
1992 for ( j = 0; j < nj; j++ )
1994 color_data[i][j] = min_value + (
PLFLT) j * step_size;
1998 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2003 for ( i = 0; i < ni; i++ )
2005 for ( j = 0; j < nj; j++ )
2007 color_data[i][j] = max_value - (
PLFLT) i * step_size;
2011 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2016 for ( i = 0; i < ni; i++ )
2018 for ( j = 0; j < nj; j++ )
2020 color_data[i][j] = max_value - (
PLFLT) j * step_size;
2026 plabort(
"plcolorbar: Invalid orientation bits" );
2032 n_steps = n_values[0];
2034 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2039 for ( i = 0; i < ni; i++ )
2041 for ( j = 0; j < nj; j++ )
2043 color_data[i][j] = values[0][i];
2047 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2052 for ( i = 0; i < ni; i++ )
2054 for ( j = 0; j < nj; j++ )
2056 color_data[i][j] = values[0][j];
2060 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2065 for ( i = 0; i < ni; i++ )
2067 for ( j = 0; j < nj; j++ )
2069 color_data[i][j] = values[0][ni - 1 - i];
2073 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2078 for ( i = 0; i < ni; i++ )
2080 for ( j = 0; j < nj; j++ )
2082 color_data[i][j] = values[0][nj - 1 - j];
2088 plabort(
"plcolorbar: Invalid side" );
2092 plimage( (
const PLFLT *
const *) color_data, ni, nj, wx_min, wx_max, wy_min, wy_max,
2093 min_value, max_value, wx_min, wx_max, wy_min, wy_max );
2104 PLFLT grid_axis[2] = { 0.0, max_abs };
2105 n_steps = n_values[0];
2107 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2109 grid.
xg = (
PLFLT *) values[0];
2110 grid.
yg = grid_axis;
2116 for ( i = 0; i < ni; i++ )
2118 for ( j = 0; j < nj; j++ )
2120 color_data[i][j] = values[0][i];
2124 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2126 grid.
xg = grid_axis;
2127 grid.
yg = (
PLFLT *) values[0];
2133 for ( i = 0; i < ni; i++ )
2135 for ( j = 0; j < nj; j++ )
2137 color_data[i][j] = values[0][j];
2141 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2143 grid.
xg = (
PLFLT *) values[0];
2144 grid.
yg = grid_axis;
2150 for ( i = 0; i < ni; i++ )
2152 for ( j = 0; j < nj; j++ )
2154 color_data[i][j] = values[0][ni - 1 - i];
2158 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2160 grid.
xg = grid_axis;
2161 grid.
yg = (
PLFLT *) values[0];
2167 for ( i = 0; i < ni; i++ )
2169 for ( j = 0; j < nj; j++ )
2171 color_data[i][j] = values[0][nj - 1 - j];
2177 plabort(
"plcolorbar: Invalid orientation" );
2181 plshades( (
const PLFLT *
const *) color_data, ni, nj, NULL, wx_min, wx_max, wy_min, wy_max,
2182 values[0], n_steps, 0, cont_color, cont_width,
plfill,
TRUE,
2183 pltr1, (
void *) ( &grid ) );
2199 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2203 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2207 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2211 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2217 plabort(
"plcolorbar: Invalid orientation" );
2223 plabort(
"plcolorbar: One of PL_COLORBAR_IMAGE, PL_COLORBAR_SHADE, or PL_COLORBAR_GRADIENT bits must be set in opt" );
2232 plvpor( 0., 1., 0., 1. );
2233 plwind( 0., 1., 0., 1. );
2238 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2239 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2240 plot_x_subpage - cap_extent, plot_x_subpage,
2241 plot_y_subpage - colorbar_height, plot_y_subpage,
2243 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2244 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2245 plot_x_subpage, plot_x_subpage + colorbar_width,
2246 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2248 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2249 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2250 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2251 plot_y_subpage - colorbar_height, plot_y_subpage,
2253 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2254 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2255 plot_x_subpage, plot_x_subpage + colorbar_width,
2256 plot_y_subpage, plot_y_subpage + cap_extent,
2262 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2263 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2264 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2265 plot_y_subpage - colorbar_height, plot_y_subpage,
2267 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2268 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2269 plot_x_subpage, plot_x_subpage + colorbar_width,
2270 plot_y_subpage, plot_y_subpage + cap_extent,
2272 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2273 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2274 plot_x_subpage - cap_extent, plot_x_subpage,
2275 plot_y_subpage - colorbar_height, plot_y_subpage,
2277 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2278 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2279 plot_x_subpage, plot_x_subpage + colorbar_width,
2280 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2284 for ( i = n_axes - 1; i >= 0; i-- )
2286 min_value = values[i][0];
2287 max_value = values[i][ n_values[i] - 1 ];
2288 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
2292 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2299 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2306 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2313 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2322 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
2326 plvpor( vx_min, vx_max, vy_min, vy_max );
2327 plwind( wx_min, wx_max, wy_min, wy_max );
2332 ticks[i], sub_ticks[i], n_values[i], values[i] );
2336 plvpor( 0., 1., 0., 1. );
2337 plwind( 0., 1., 0., 1. );
2344 plot_x_subpage_bb + colorbar_width_l,
2345 plot_x_subpage_bb + colorbar_width_l,
2350 plot_y_subpage_bb - colorbar_height_l,
2351 plot_y_subpage_bb - colorbar_height_l,
2359 pllsty( line_style_save );
2364 plvpor( label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax );
2372 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
2373 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );