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 ) ) )
534 PLFLT text_justification,
535 const PLINT *text_colors,
const char *
const *
text,
536 const PLINT *box_colors,
const PLINT *box_patterns,
537 const PLFLT *box_scales,
const PLFLT *box_line_widths,
538 const PLINT *line_colors,
const PLINT *line_styles,
539 const PLFLT *line_widths,
540 const PLINT *symbol_colors,
const PLFLT *symbol_scales,
541 const PLINT *symbol_numbers,
const char *
const *symbols )
545 PLFLT plot_x, plot_x_end, plot_x_subpage, plot_x_end_subpage;
546 PLFLT plot_y, plot_y_subpage;
547 PLFLT text_x, text_y, text_x_subpage, text_y_subpage;
549 PLFLT character_height, character_width, symbol_width = 0.0;
551 PLFLT ty, xshift, drow, dcolumn;
553 PLFLT dxs, *xs = NULL, *ys = NULL,
xl[2],
yl[2], xbox[4], ybox[4];
556 PLINT col0_save = plsc->icol0,
557 line_style_save = plsc->line_style,
558 pattern_save = plsc->patt;
559 PLFLT line_width_save = plsc->width;
560 PLFLT text_scale_save = plsc->chrht / plsc->chrdef;
562 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
565 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
568 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
570 PLFLT x_subpage_per_mm, y_subpage_per_mm, text_width0 = 0., text_width;
571 PLFLT width_border, column_separation,
572 legend_width, legend_height, legend_width_ac, legend_height_ac;
573 PLFLT x_legend_position, y_legend_position, xsign, ysign;
576 PLINT some_symbols = 0;
577 PLINT max_symbol_numbers = 0;
578 PLINT irow = 0, icolumn = 0;
581 nrow =
MAX( nrow, 1 );
582 ncolumn =
MAX( ncolumn, 1 );
583 if ( nrow * ncolumn < nlegend )
586 if ( ncolumn < nrow )
587 ncolumn = ( nlegend % nrow ) ? ( nlegend / nrow ) + 1 : nlegend / nrow;
589 nrow = ( nlegend % ncolumn ) ? ( nlegend / ncolumn ) + 1 : nlegend / ncolumn;
598 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
600 plabort(
"pllegend: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
606 plabort(
"pllegend: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
614 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
616 plabort(
"pllegend: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
624 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
626 plabort(
"pllegend: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
633 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
636 if ( position & PL_POSITION_SUBPAGE )
646 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
650 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
660 for ( i = 0; i < nlegend; i++ )
668 max_symbol_numbers =
MAX( max_symbol_numbers, symbol_numbers[i] );
675 character_width = character_height;
679 for ( i = 0; i < nlegend; i++ )
682 text_width0 =
MAX( text_width0,
plstrl( text[i] ) );
687 text_width0 = x_subpage_per_mm * text_width0;
690 text_width = text_width0 + text_offset * character_width;
695 width_border = 0.4 * character_width;
697 column_separation = 2.0 * character_width;
700 legend_width = 2. * width_border + ( ncolumn - 1 ) * column_separation +
701 ncolumn * ( text_width +
703 legend_height = nrow * text_spacing * character_height;
709 *p_legend_width = legend_width_ac;
710 *p_legend_height = legend_height_ac;
714 dcolumn = column_separation + text_width +
716 drow = text_spacing * character_height;
718 legend_position( position, legend_width_ac, legend_height_ac, &x_legend_position, &y_legend_position, &xsign, &ysign );
719 plot_x = x * xsign + x_legend_position;
720 plot_y = y * ysign + y_legend_position;
721 plot_x_end = plot_x + plot_width;
731 text_offset * character_width;
739 plot_x_subpage + legend_width,
740 plot_x_subpage + legend_width,
744 plot_y_subpage - legend_height,
745 plot_y_subpage - legend_height,
759 plot_x_subpage + legend_width,
760 plot_x_subpage + legend_width,
765 plot_y_subpage - legend_height,
766 plot_y_subpage - legend_height,
774 pllsty( line_style_save );
780 text_x_subpage = plot_x_subpage;
781 plot_x_subpage += text_width;
782 plot_x_end_subpage += text_width;
785 plot_x_subpage += width_border;
786 plot_x_end_subpage += width_border;
787 text_x_subpage += width_border;
791 max_symbol_numbers =
MAX( 2, max_symbol_numbers );
792 if ( ( ( xs = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) ||
793 ( ( ys = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) )
795 plexit(
"pllegend: Insufficient memory" );
807 for ( i = 0; i < nlegend; i++ )
810 ty = text_y_subpage - ( (double) irow + 0.5 ) * drow;
811 xshift = (double) icolumn * dcolumn;
815 plptex( text_x_subpage + xshift + text_justification * text_width0, ty, 0.1, 0.0, text_justification, text[i] );
822 plpsty( box_patterns[i] );
824 xbox[0] = plot_x_subpage + xshift;
826 xbox[2] = plot_x_end_subpage + xshift;
828 ybox[0] = ty + 0.5 * drow * box_scales[i];
829 ybox[1] = ty - 0.5 * drow * box_scales[i];
830 ybox[2] = ty - 0.5 * drow * box_scales[i];
831 ybox[3] = ty + 0.5 * drow * box_scales[i];
833 pllsty( line_style_save );
841 xl[0] = plot_x_subpage + xshift;
842 xl[1] = plot_x_end_subpage + xshift;
846 pllsty( line_style_save );
852 plcol0( symbol_colors[i] );
853 plschr( 0., symbol_scales[i] );
854 dxs = ( plot_x_end_subpage - plot_x_subpage - symbol_width ) / (
double) (
MAX( symbol_numbers[i], 2 ) - 1 );
855 for ( j = 0; j < symbol_numbers[i]; j++ )
857 xs[j] = plot_x_subpage + xshift +
858 0.5 * symbol_width + dxs * (double) j;
861 plstring( symbol_numbers[i], xs, ys, symbols[i] );
869 if ( icolumn >= ncolumn )
893 plschr( 0., text_scale_save );
895 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
896 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );
912 size_t length = strlen(
string );
913 size_t prefix_length = strcspn(
string, characters );
914 if ( prefix_length < length )
918 memmove(
string + prefix_length,
string + prefix_length + 1, length - prefix_length );
950 PLINT col0_save = plsc->icol0;
998 plexit(
"draw_cap: internal error. Incorrect orientation" );
1039 const char *edge_string;
1040 size_t length_axis_opts = strlen( axis_opts );
1041 char *local_axis_opts;
1045 if ( ( local_axis_opts = (
char *) malloc( ( length_axis_opts + 1 ) *
sizeof (
char ) ) ) == NULL )
1047 plexit(
"draw_box: Insufficient memory" );
1049 strcpy( local_axis_opts, axis_opts );
1051 plsc->if_boxbb = if_bb;
1065 plsc->if_boxbb =
FALSE;
1066 free( local_axis_opts );
1082 plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks );
1086 plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 );
1088 plsc->if_boxbb =
FALSE;
1090 free( local_axis_opts );
1121 PLFLT label_offset = 1.2;
1147 PLFLT parallel_height_mm = 0.0, perpendicular_height_mm = 0.0,
1148 default_mm, char_height_mm;
1159 opt = opt & ~PL_COLORBAR_LABEL_TOP;
1166 opt = opt & ~PL_COLORBAR_LABEL_LEFT;
1173 opt = opt & ~PL_COLORBAR_LABEL_BOTTOM;
1181 plgchr( &default_mm, &char_height_mm );
1190 plsc->boxbb_xmin = plsc->vppxmi / plsc->xpmm;
1191 plsc->boxbb_xmax = plsc->vppxma / plsc->xpmm;
1192 plsc->boxbb_ymin = plsc->vppymi / plsc->ypmm;
1193 plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm;
1200 parallel_height_mm = ( label_offset + 0.8 ) * char_height_mm;
1207 perpendicular_height_mm = ( label_offset - 0.5 + 0.0 ) * char_height_mm;
1209 if ( opt & PL_COLORBAR_LABEL_LEFT )
1217 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1218 plsc->xpmm - parallel_height_mm );
1219 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1220 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1221 plsc->ypmm - 0.5 * label_length_mm );
1222 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1223 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1224 plsc->ypmm + 0.5 * label_length_mm );
1231 label_offset -= 0.5;
1234 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1235 plsc->xpmm - perpendicular_height_mm - label_length_mm );
1240 else if ( opt & PL_COLORBAR_LABEL_RIGHT )
1248 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1249 plsc->xpmm + parallel_height_mm );
1250 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1251 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1252 plsc->ypmm - 0.5 * label_length_mm );
1253 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1254 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1255 plsc->ypmm + 0.5 * label_length_mm );
1262 label_offset -= 0.5;
1265 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1266 plsc->xpmm + perpendicular_height_mm + label_length_mm );
1271 else if ( opt & PL_COLORBAR_LABEL_TOP )
1278 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, plsc->vppyma /
1279 plsc->ypmm + parallel_height_mm );
1280 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1281 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1282 plsc->xpmm - 0.5 * label_length_mm );
1283 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1284 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1285 plsc->xpmm + 0.5 * label_length_mm );
1288 else if ( opt & PL_COLORBAR_LABEL_BOTTOM )
1295 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, plsc->vppymi /
1296 plsc->ypmm - parallel_height_mm );
1297 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1298 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1299 plsc->xpmm - 0.5 * label_length_mm );
1300 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1301 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1302 plsc->xpmm + 0.5 * label_length_mm );
1306 plmtex( opt_label, label_offset, 0.5, just, label );
1326 PLFLT prior_bb_height,
1327 PLFLT *p_colorbar_width_bb,
PLFLT *p_colorbar_height_bb,
1328 PLFLT *p_colorbar_width_ac,
PLFLT *p_colorbar_height_ac,
1329 PLFLT *p_plot_x_subpage_bb,
PLFLT *p_plot_y_subpage_bb,
1333 PLFLT x_colorbar_position, y_colorbar_position, xsign, ysign;
1334 PLFLT plot_x, plot_y;
1337 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1338 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1341 *p_colorbar_width_bb = ( plsc->boxbb_xmax - plsc->boxbb_xmin ) * spxpmm;
1342 *p_colorbar_height_bb = ( plsc->boxbb_ymax - plsc->boxbb_ymin ) * spypmm;
1348 *p_dx_subpage = -plsc->boxbb_xmin * spxpmm;
1349 *p_dy_subpage = prior_bb_height - plsc->boxbb_ymax * spypmm;
1361 legend_position( position, *p_colorbar_width_ac, *p_colorbar_height_ac, &x_colorbar_position, &y_colorbar_position, &xsign, &ysign );
1362 plot_x = x * xsign + x_colorbar_position;
1363 plot_y = y * ysign + y_colorbar_position;
1477 PLFLT min_value, max_value, max_abs;
1480 PLFLT cap_extent, cap_extent_mm;
1487 PLFLT cap_angle = 45.;
1492 PLFLT cap_ratio = 0.5 / tan(
PI / 360. * cap_angle );
1495 PLFLT aspspp = ( ( plsc->sppxma - plsc->sppxmi ) / plsc->xpmm ) /
1496 ( ( plsc->sppyma - plsc->sppymi ) / plsc->ypmm );
1499 PLFLT min_color, max_color;
1502 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
1505 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
1509 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
1512 PLINT col0_save = plsc->icol0,
1513 line_style_save = plsc->line_style;
1516 PLFLT plot_x_subpage_bb, plot_y_subpage_bb;
1523 PLFLT colorbar_width, colorbar_height,
1524 colorbar_width_d, colorbar_height_d,
1525 colorbar_width_l, colorbar_height_l;
1531 PLFLT colorbar_width_ac, colorbar_height_ac,
1532 colorbar_width_mm, colorbar_height_mm;
1538 PLFLT dx_subpage_omd, dy_subpage_omd, dx_subpage_dml, dy_subpage_dml;
1539 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;
1542 PLFLT plot_x_subpage, plot_y_subpage;
1545 PLFLT vx_min = 0.0, vx_max = 0.0, vy_min = 0.0, vy_max = 0.0;
1548 PLFLT wx_min = 0.0, wx_max = 0.0, wy_min = 0.0, wy_max = 0.0;
1554 PLINT i, j, ni = 0, nj = 0, n_steps;
1558 PLBOOL if_edge_b = 0, if_edge_c = 0, if_edge_u = 0, if_edge_w = 0;
1562 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1563 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1566 PLFLT label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax;
1573 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
1575 plabort(
"plcolorbar: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
1581 plabort(
"plcolorbar: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
1589 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
1591 plabort(
"plcolorbar: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
1599 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
1601 plabort(
"plcolorbar: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
1607 plabort(
"plcolorbar: At least one axis must be specified" );
1614 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
1617 if ( position & PL_POSITION_SUBPAGE )
1618 plvpor( 0., 1., 0., 1. );
1627 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
1631 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
1645 for ( i = 0; i < n_axes; i++ )
1647 if_edge_b = if_edge_b ||
plP_stsearch( axis_opts[i],
'b' );
1648 if_edge_c = if_edge_c ||
plP_stsearch( axis_opts[i],
'c' );
1649 if_edge_u = if_edge_u ||
plP_stsearch( axis_opts[i],
'u' );
1650 if_edge_w = if_edge_w ||
plP_stsearch( axis_opts[i],
'w' );
1652 if_edge = if_edge_b && if_edge_c && !( if_edge_u || if_edge_w );
1663 colorbar_width_d = colorbar_width;
1664 colorbar_height_d = colorbar_height;
1665 colorbar_width_mm = colorbar_width / spxpmm;
1666 colorbar_height_mm = colorbar_height / spypmm;
1671 cap_extent = cap_ratio * colorbar_height / aspspp;
1672 cap_extent_mm = cap_extent / spxpmm;
1676 cap_extent = cap_ratio * colorbar_width * aspspp;
1677 cap_extent_mm = cap_extent / spypmm;
1680 for ( i = n_axes - 1; i >= 0; i-- )
1682 min_value = values[i][0];
1683 max_value = values[i][ n_values[i] - 1 ];
1684 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
1702 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1709 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1718 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1725 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1726 plwind( wx_min, wx_max, wy_min, wy_max );
1731 ticks[i], sub_ticks[i], n_values[i], values[i] );
1733 if ( i == n_axes - 1 )
1737 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1738 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1739 if ( opt & PL_COLORBAR_ORIENT_TOP )
1740 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1741 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1742 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1743 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1744 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1748 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1749 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1750 if ( opt & PL_COLORBAR_ORIENT_TOP )
1751 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1752 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1753 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1754 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1755 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1761 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1763 &colorbar_width_d, &colorbar_height_d,
1764 &colorbar_width_ac, &colorbar_height_ac,
1765 &plot_x_subpage_bb, &plot_y_subpage_bb,
1766 &dx_subpage_omd, &dy_subpage_omd );
1771 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1773 dx_subpage_omd_accu += dx_subpage_omd;
1774 dy_subpage_omd_accu += dy_subpage_omd;
1778 colorbar_width_l = colorbar_width_d;
1779 colorbar_height_l = colorbar_height_d;
1787 plvpor( 0., colorbar_width_l, 0., colorbar_height_l );
1788 plwind( wx_min, wx_max, wy_min, wy_max );
1795 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1797 &colorbar_width_l, &colorbar_height_l,
1798 &colorbar_width_ac, &colorbar_height_ac,
1799 &plot_x_subpage_bb, &plot_y_subpage_bb,
1800 &dx_subpage_dml, &dy_subpage_dml );
1802 dx_subpage_dml_accu += dx_subpage_dml;
1803 dy_subpage_dml_accu += dy_subpage_dml;
1808 plot_x_subpage = plot_x_subpage_bb + dx_subpage_omd_accu + dx_subpage_dml_accu;
1809 plot_y_subpage = plot_y_subpage_bb + dy_subpage_omd_accu + dy_subpage_dml_accu;
1812 label_vpor_xmin = plot_x_subpage_bb + dx_subpage_dml_accu;
1813 label_vpor_xmax = label_vpor_xmin + colorbar_width_d;
1814 label_vpor_ymax = plot_y_subpage_bb + dy_subpage_dml_accu;
1815 label_vpor_ymin = label_vpor_ymax - colorbar_height_d;
1819 *p_colorbar_width = colorbar_width_ac;
1820 *p_colorbar_height = colorbar_height_ac;
1826 vx_min = plot_x_subpage;
1827 vx_max = plot_x_subpage + colorbar_width;
1828 vy_min = plot_y_subpage - colorbar_height;
1829 vy_max = plot_y_subpage;
1833 vx_min = plot_x_subpage;
1834 vx_max = plot_x_subpage + colorbar_width;
1835 vy_min = plot_y_subpage - colorbar_height;
1836 vy_max = plot_y_subpage;
1838 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1840 vx_min = plot_x_subpage;
1841 vx_max = plot_x_subpage + colorbar_width;
1842 vy_min = plot_y_subpage - colorbar_height;
1843 vy_max = plot_y_subpage;
1845 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1847 vx_min = plot_x_subpage;
1848 vx_max = plot_x_subpage + colorbar_width;
1849 vy_min = plot_y_subpage - colorbar_height;
1850 vy_max = plot_y_subpage;
1854 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1858 plvpor( 0., 1., 0., 1. );
1859 plwind( 0., 1., 0., 1. );
1866 plot_x_subpage_bb + colorbar_width_l,
1867 plot_x_subpage_bb + colorbar_width_l,
1871 plot_y_subpage_bb - colorbar_height_l,
1872 plot_y_subpage_bb - colorbar_height_l,
1882 plvpor( vx_min, vx_max, vy_min, vy_max );
1883 plwind( wx_min, wx_max, wy_min, wy_max );
1891 if ( n_values[0] == 2 )
1896 n_steps = plsc->ncol1;
1897 step_size = ( max_value - min_value ) / (
PLFLT) n_steps;
1898 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1903 for ( i = 0; i < ni; i++ )
1905 for ( j = 0; j < nj; j++ )
1907 color_data[i][j] = min_value + (
PLFLT) i * step_size;
1911 else if ( opt & PL_COLORBAR_ORIENT_TOP )
1916 for ( i = 0; i < ni; i++ )
1918 for ( j = 0; j < nj; j++ )
1920 color_data[i][j] = min_value + (
PLFLT) j * step_size;
1924 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1929 for ( i = 0; i < ni; i++ )
1931 for ( j = 0; j < nj; j++ )
1933 color_data[i][j] = max_value - (
PLFLT) i * step_size;
1937 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1942 for ( i = 0; i < ni; i++ )
1944 for ( j = 0; j < nj; j++ )
1946 color_data[i][j] = max_value - (
PLFLT) j * step_size;
1952 plabort(
"plcolorbar: Invalid orientation bits" );
1958 n_steps = n_values[0];
1960 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1965 for ( i = 0; i < ni; i++ )
1967 for ( j = 0; j < nj; j++ )
1969 color_data[i][j] = values[0][i];
1973 else if ( opt & PL_COLORBAR_ORIENT_TOP )
1978 for ( i = 0; i < ni; i++ )
1980 for ( j = 0; j < nj; j++ )
1982 color_data[i][j] = values[0][j];
1986 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1991 for ( i = 0; i < ni; i++ )
1993 for ( j = 0; j < nj; j++ )
1995 color_data[i][j] = values[0][ni - 1 - i];
1999 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2004 for ( i = 0; i < ni; i++ )
2006 for ( j = 0; j < nj; j++ )
2008 color_data[i][j] = values[0][nj - 1 - j];
2014 plabort(
"plcolorbar: Invalid side" );
2018 plimage( (
const PLFLT *
const *) color_data, ni, nj, wx_min, wx_max, wy_min, wy_max,
2019 min_value, max_value, wx_min, wx_max, wy_min, wy_max );
2030 PLFLT grid_axis[2] = { 0.0, max_abs };
2031 n_steps = n_values[0];
2033 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2035 grid.
xg = (
PLFLT *) values[0];
2036 grid.
yg = grid_axis;
2042 for ( i = 0; i < ni; i++ )
2044 for ( j = 0; j < nj; j++ )
2046 color_data[i][j] = values[0][i];
2050 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2052 grid.
xg = grid_axis;
2053 grid.
yg = (
PLFLT *) values[0];
2059 for ( i = 0; i < ni; i++ )
2061 for ( j = 0; j < nj; j++ )
2063 color_data[i][j] = values[0][j];
2067 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2069 grid.
xg = (
PLFLT *) values[0];
2070 grid.
yg = grid_axis;
2076 for ( i = 0; i < ni; i++ )
2078 for ( j = 0; j < nj; j++ )
2080 color_data[i][j] = values[0][ni - 1 - i];
2084 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2086 grid.
xg = grid_axis;
2087 grid.
yg = (
PLFLT *) values[0];
2093 for ( i = 0; i < ni; i++ )
2095 for ( j = 0; j < nj; j++ )
2097 color_data[i][j] = values[0][nj - 1 - j];
2103 plabort(
"plcolorbar: Invalid orientation" );
2107 plshades( (
const PLFLT *
const *) color_data, ni, nj, NULL, wx_min, wx_max, wy_min, wy_max,
2108 values[0], n_steps, 0, cont_color, cont_width,
plfill,
TRUE,
2109 pltr1, (
void *) ( &grid ) );
2125 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2129 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2133 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2137 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2143 plabort(
"plcolorbar: Invalid orientation" );
2149 plabort(
"plcolorbar: One of PL_COLORBAR_IMAGE, PL_COLORBAR_SHADE, or PL_COLORBAR_GRADIENT bits must be set in opt" );
2158 plvpor( 0., 1., 0., 1. );
2159 plwind( 0., 1., 0., 1. );
2164 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2165 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2166 plot_x_subpage - cap_extent, plot_x_subpage,
2167 plot_y_subpage - colorbar_height, plot_y_subpage,
2169 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2170 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2171 plot_x_subpage, plot_x_subpage + colorbar_width,
2172 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2174 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2175 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2176 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2177 plot_y_subpage - colorbar_height, plot_y_subpage,
2179 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2180 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2181 plot_x_subpage, plot_x_subpage + colorbar_width,
2182 plot_y_subpage, plot_y_subpage + cap_extent,
2188 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2189 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2190 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2191 plot_y_subpage - colorbar_height, plot_y_subpage,
2193 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2194 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2195 plot_x_subpage, plot_x_subpage + colorbar_width,
2196 plot_y_subpage, plot_y_subpage + cap_extent,
2198 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2199 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2200 plot_x_subpage - cap_extent, plot_x_subpage,
2201 plot_y_subpage - colorbar_height, plot_y_subpage,
2203 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2204 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2205 plot_x_subpage, plot_x_subpage + colorbar_width,
2206 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2210 for ( i = n_axes - 1; i >= 0; i-- )
2212 min_value = values[i][0];
2213 max_value = values[i][ n_values[i] - 1 ];
2214 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
2218 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2225 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2232 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2239 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2248 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
2252 plvpor( vx_min, vx_max, vy_min, vy_max );
2253 plwind( wx_min, wx_max, wy_min, wy_max );
2258 ticks[i], sub_ticks[i], n_values[i], values[i] );
2262 plvpor( 0., 1., 0., 1. );
2263 plwind( 0., 1., 0., 1. );
2270 plot_x_subpage_bb + colorbar_width_l,
2271 plot_x_subpage_bb + colorbar_width_l,
2276 plot_y_subpage_bb - colorbar_height_l,
2277 plot_y_subpage_bb - colorbar_height_l,
2285 pllsty( line_style_save );
2290 plvpor( label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax );
2298 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
2299 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );