48 if ( plsc->level < 1 )
50 plabort(
"plgvpsp: Please call plinit first" );
53 if ( ( plsc->cursub <= 0 ) || ( plsc->cursub > ( plsc->nsubx * plsc->nsuby ) ) )
55 plabort(
"plgvpsp: Please call pladv or plenv to go to a subpage" );
58 *p_xmin = ( plsc->vpdxmi - plsc->spdxmi ) / ( plsc->spdxma - plsc->spdxmi );
59 *p_xmax = ( plsc->vpdxma - plsc->spdxmi ) / ( plsc->spdxma - plsc->spdxmi );
60 *p_ymin = ( plsc->vpdymi - plsc->spdymi ) / ( plsc->spdyma - plsc->spdymi );
61 *p_ymax = ( plsc->vpdyma - plsc->spdymi ) / ( plsc->spdyma - plsc->spdymi );
88 PLFLT *x_legend_position,
PLFLT *y_legend_position,
101 PLFLT xorigin = 0.0, yorigin = 0.0, xlegend = 0.0, ylegend = 0.0;
113 xlegend = -legend_width;
121 ylegend = legend_height;
125 plexit(
"legend_position: internal logic error 1" );
131 ylegend = 0.5 * legend_height;
134 xlegend = -legend_width;
143 plexit(
"legend_position: internal logic error 2" );
146 else if ( position & PL_POSITION_BOTTOM )
151 xlegend = -legend_width;
152 ylegend = legend_height;
163 plexit(
"legend_position: internal logic error 3" );
168 plexit(
"legend_position: internal logic error 4" );
171 else if ( !( position & PL_POSITION_RIGHT ) && !( position &
PL_POSITION_LEFT ) )
174 xlegend = -0.5 * legend_width;
185 ylegend = legend_height;
189 plexit(
"legend_position: internal logic error 5" );
197 ylegend = legend_height;
206 plexit(
"legend_position: internal logic error 6" );
211 plexit(
"legend_position: internal logic error 7" );
214 else if ( position & PL_POSITION_LEFT )
228 xlegend = -legend_width;
229 ylegend = legend_height;
234 plexit(
"legend_position: internal logic error 8" );
240 ylegend = 0.5 * legend_height;
247 xlegend = -legend_width;
252 plexit(
"legend_position: internal logic error 9" );
255 else if ( position & PL_POSITION_BOTTOM )
260 ylegend = legend_height;
265 xlegend = -legend_width;
272 plexit(
"legend_position: internal logic error 10" );
277 plexit(
"legend_position: internal logic error 11" );
282 plexit(
"legend_position: internal logic error 12" );
284 *x_legend_position = xorigin + xlegend;
285 *y_legend_position = yorigin + ylegend;
298 PLFLT mxmin, mxmax, mymin, mymax;
299 plgspa( &mxmin, &mxmax, &mymin, &mymax );
300 *x_subpage_per_mm = 1. / ( mxmax - mxmin );
301 *y_subpage_per_mm = 1. / ( mymax - mymin );
315 PLFLT default_mm, char_height_mm;
316 PLFLT x_subpage_per_mm, y_subpage_per_mm;
320 plgchr( &default_mm, &char_height_mm );
324 default_mm = plsc->symdef;
325 char_height_mm = plsc->symht;
328 return ( char_height_mm * y_subpage_per_mm );
344 #define adopted_to_subpage_x( nx ) ( ( xdmin_adopted ) + ( nx ) * ( ( xdmax_adopted ) - ( xdmin_adopted ) ) )
359 #define subpage_to_adopted_x( nx ) ( ( nx - xdmin_adopted ) / ( ( xdmax_adopted ) - ( xdmin_adopted ) ) )
374 #define adopted_to_subpage_y( ny ) ( ( ydmin_adopted ) + ( ny ) * ( ( ydmax_adopted ) - ( ydmin_adopted ) ) )
389 #define subpage_to_adopted_y( ny ) ( ( ny - ydmin_adopted ) / ( ( ydmax_adopted ) - ( ydmin_adopted ) ) )
537 PLFLT text_justification,
548 PLFLT plot_x, plot_x_end, plot_x_subpage, plot_x_end_subpage;
549 PLFLT plot_y, plot_y_subpage;
550 PLFLT text_x, text_y, text_x_subpage, text_y_subpage;
552 PLFLT character_height, character_width, symbol_width = 0.0;
554 PLFLT ty, xshift, drow, dcolumn;
556 PLFLT dxs, *xs = NULL, *ys = NULL, xl[2], yl[2], xbox[4], ybox[4];
559 PLINT col0_save = plsc->icol0,
560 line_style_save = plsc->line_style,
561 pattern_save = plsc->patt;
562 PLFLT line_width_save = plsc->width;
563 PLFLT text_scale_save = plsc->chrht / plsc->chrdef;
565 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
568 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
571 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
573 PLFLT x_subpage_per_mm, y_subpage_per_mm, text_width0 = 0., text_width;
574 PLFLT width_border, column_separation,
575 legend_width, legend_height, legend_width_ac, legend_height_ac;
576 PLFLT x_legend_position, y_legend_position, xsign, ysign;
578 PLINT some_symbols = 0;
579 PLINT max_symbol_numbers = 0;
580 PLINT irow = 0, icolumn = 0;
581 int some_boxes = 0, some_lines = 0;
584 nrow =
MAX( nrow, 1 );
585 ncolumn =
MAX( ncolumn, 1 );
586 if ( nrow * ncolumn < nlegend )
589 if ( ncolumn < nrow )
590 ncolumn = ( nlegend % nrow ) ? ( nlegend / nrow ) + 1 : nlegend / nrow;
592 nrow = ( nlegend % ncolumn ) ? ( nlegend / ncolumn ) + 1 : nlegend / ncolumn;
601 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
603 plabort(
"pllegend: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
609 plabort(
"pllegend: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
617 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
619 plabort(
"pllegend: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
627 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
629 plabort(
"pllegend: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
636 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
639 if ( position & PL_POSITION_SUBPAGE )
649 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
653 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
663 for ( i = 0; i < nlegend; i++ )
671 if ( symbol_numbers != NULL )
672 max_symbol_numbers =
MAX( max_symbol_numbers, symbol_numbers[i] );
678 if ( some_boxes && ( box_colors == NULL || box_patterns == NULL || box_scales == NULL || box_line_widths == NULL ) )
680 plabort(
"pllegend: all box_* arrays must be defined when the PL_LEGEND_COLOR_BOX bit is set." );
684 if ( some_lines && ( line_colors == NULL || line_styles == NULL || line_widths == NULL ) )
686 plabort(
"pllegend: all line_* arrays must be defined when the PL_LEGEND_LINE bit is set." );
690 if ( some_symbols && ( symbol_colors == NULL || symbol_scales == NULL || symbol_numbers == NULL ) )
692 plabort(
"pllegend: all symbol_* arrays must be defined when the PL_LEGEND_SYMBOL bit is set." );
698 character_width = character_height;
702 for ( i = 0; i < nlegend; i++ )
705 text_width0 =
MAX( text_width0,
plstrl( text[i] ) );
710 text_width0 = x_subpage_per_mm * text_width0;
713 text_width = text_width0 + text_offset * character_width;
718 width_border = 0.4 * character_width;
720 column_separation = 2.0 * character_width;
723 legend_width = 2. * width_border + ( ncolumn - 1 ) * column_separation +
724 ncolumn * ( text_width +
726 legend_height = nrow * text_spacing * character_height;
732 *p_legend_width = legend_width_ac;
733 *p_legend_height = legend_height_ac;
737 dcolumn = column_separation + text_width +
739 drow = text_spacing * character_height;
741 legend_position( position, legend_width_ac, legend_height_ac, &x_legend_position, &y_legend_position, &xsign, &ysign );
742 plot_x = x * xsign + x_legend_position;
743 plot_y = y * ysign + y_legend_position;
744 plot_x_end = plot_x + plot_width;
754 text_offset * character_width;
762 plot_x_subpage + legend_width,
763 plot_x_subpage + legend_width,
767 plot_y_subpage - legend_height,
768 plot_y_subpage - legend_height,
782 plot_x_subpage + legend_width,
783 plot_x_subpage + legend_width,
788 plot_y_subpage - legend_height,
789 plot_y_subpage - legend_height,
797 pllsty( line_style_save );
803 text_x_subpage = plot_x_subpage;
804 plot_x_subpage += text_width;
805 plot_x_end_subpage += text_width;
808 plot_x_subpage += width_border;
809 plot_x_end_subpage += width_border;
810 text_x_subpage += width_border;
814 max_symbol_numbers =
MAX( 2, max_symbol_numbers );
815 if ( ( ( xs = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) ||
816 ( ( ys = (
PLFLT *) malloc( (
size_t) max_symbol_numbers *
sizeof (
PLFLT ) ) ) == NULL ) )
818 plexit(
"pllegend: Insufficient memory" );
830 for ( i = 0; i < nlegend; i++ )
833 ty = text_y_subpage - ( (double) irow + 0.5 ) * drow;
834 xshift = (double) icolumn * dcolumn;
838 plptex( text_x_subpage + xshift + text_justification * text_width0, ty, 0.1, 0.0, text_justification, text[i] );
845 plpsty( box_patterns[i] );
847 xbox[0] = plot_x_subpage + xshift;
849 xbox[2] = plot_x_end_subpage + xshift;
851 ybox[0] = ty + 0.5 * drow * box_scales[i];
852 ybox[1] = ty - 0.5 * drow * box_scales[i];
853 ybox[2] = ty - 0.5 * drow * box_scales[i];
854 ybox[3] = ty + 0.5 * drow * box_scales[i];
856 pllsty( line_style_save );
864 xl[0] = plot_x_subpage + xshift;
865 xl[1] = plot_x_end_subpage + xshift;
869 pllsty( line_style_save );
875 plcol0( symbol_colors[i] );
876 plschr( 0., symbol_scales[i] );
877 dxs = ( plot_x_end_subpage - plot_x_subpage - symbol_width ) / (
double) (
MAX( symbol_numbers[i], 2 ) - 1 );
878 for ( j = 0; j < symbol_numbers[i]; j++ )
880 xs[j] = plot_x_subpage + xshift +
881 0.5 * symbol_width + dxs * (double) j;
884 plstring( symbol_numbers[i], xs, ys, symbols[i] );
892 if ( icolumn >= ncolumn )
916 plschr( 0., text_scale_save );
918 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
919 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );
937 for ( src = dst =
string; *src !=
'\0'; src++ )
940 while ( ( *ptr !=
'\0' ) && ( *src != *ptr ) )
977 PLINT col0_save = plsc->icol0;
978 PLFLT xhalf = 0.5 * ( xmin + xmax );
979 PLFLT yhalf = 0.5 * ( ymin + ymax );
1025 plexit(
"draw_cap: internal error. Incorrect orientation" );
1067 size_t length_axis_opts = strlen( axis_opts );
1068 char *local_axis_opts;
1072 if ( ( local_axis_opts = (
char *) malloc( ( length_axis_opts + 1 ) *
sizeof (
char ) ) ) == NULL )
1074 plexit(
"draw_box: Insufficient memory" );
1076 strcpy( local_axis_opts, axis_opts );
1078 plsc->if_boxbb = if_bb;
1092 plsc->if_boxbb =
FALSE;
1093 free( local_axis_opts );
1109 plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks );
1113 plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 );
1115 plsc->if_boxbb =
FALSE;
1117 free( local_axis_opts );
1145 PLFLT label_offset = 1.2;
1171 PLFLT parallel_height_mm = 0.0, perpendicular_height_mm = 0.0,
1172 default_mm, char_height_mm;
1183 opt = opt & ~PL_COLORBAR_LABEL_TOP;
1190 opt = opt & ~PL_COLORBAR_LABEL_LEFT;
1197 opt = opt & ~PL_COLORBAR_LABEL_BOTTOM;
1205 plgchr( &default_mm, &char_height_mm );
1214 plsc->boxbb_xmin = plsc->vppxmi / plsc->xpmm;
1215 plsc->boxbb_xmax = plsc->vppxma / plsc->xpmm;
1216 plsc->boxbb_ymin = plsc->vppymi / plsc->ypmm;
1217 plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm;
1224 parallel_height_mm = ( label_offset + 0.8 ) * char_height_mm;
1231 perpendicular_height_mm = ( label_offset - 0.5 + 0.0 ) * char_height_mm;
1233 if ( opt & PL_COLORBAR_LABEL_LEFT )
1241 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1242 plsc->xpmm - parallel_height_mm );
1243 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1244 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1245 plsc->ypmm - 0.5 * label_length_mm );
1246 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1247 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1248 plsc->ypmm + 0.5 * label_length_mm );
1255 label_offset -= 0.5;
1258 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, plsc->vppxmi /
1259 plsc->xpmm - perpendicular_height_mm - label_length_mm );
1264 else if ( opt & PL_COLORBAR_LABEL_RIGHT )
1272 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1273 plsc->xpmm + parallel_height_mm );
1274 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin,
1275 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1276 plsc->ypmm - 0.5 * label_length_mm );
1277 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax,
1278 0.5 * ( plsc->vppymi + plsc->vppyma ) /
1279 plsc->ypmm + 0.5 * label_length_mm );
1286 label_offset -= 0.5;
1289 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, plsc->vppxma /
1290 plsc->xpmm + perpendicular_height_mm + label_length_mm );
1295 else if ( opt & PL_COLORBAR_LABEL_TOP )
1302 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, plsc->vppyma /
1303 plsc->ypmm + parallel_height_mm );
1304 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1305 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1306 plsc->xpmm - 0.5 * label_length_mm );
1307 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1308 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1309 plsc->xpmm + 0.5 * label_length_mm );
1312 else if ( opt & PL_COLORBAR_LABEL_BOTTOM )
1319 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, plsc->vppymi /
1320 plsc->ypmm - parallel_height_mm );
1321 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin,
1322 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1323 plsc->xpmm - 0.5 * label_length_mm );
1324 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax,
1325 0.5 * ( plsc->vppxmi + plsc->vppxma ) /
1326 plsc->xpmm + 0.5 * label_length_mm );
1330 plmtex( opt_label, label_offset, 0.5, just, label );
1350 PLFLT prior_bb_height,
1351 PLFLT *p_colorbar_width_bb,
PLFLT *p_colorbar_height_bb,
1352 PLFLT *p_colorbar_width_ac,
PLFLT *p_colorbar_height_ac,
1353 PLFLT *p_plot_x_subpage_bb,
PLFLT *p_plot_y_subpage_bb,
1357 PLFLT x_colorbar_position, y_colorbar_position, xsign, ysign;
1358 PLFLT plot_x, plot_y;
1361 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1362 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1365 *p_colorbar_width_bb = ( plsc->boxbb_xmax - plsc->boxbb_xmin ) * spxpmm;
1366 *p_colorbar_height_bb = ( plsc->boxbb_ymax - plsc->boxbb_ymin ) * spypmm;
1372 *p_dx_subpage = -plsc->boxbb_xmin * spxpmm;
1373 *p_dy_subpage = prior_bb_height - plsc->boxbb_ymax * spypmm;
1385 legend_position( position, *p_colorbar_width_ac, *p_colorbar_height_ac, &x_colorbar_position, &y_colorbar_position, &xsign, &ysign );
1386 plot_x = x * xsign + x_colorbar_position;
1387 plot_y = y * ysign + y_colorbar_position;
1543 PLFLT min_value = 0., max_value = 0., max_abs = 0.;
1546 PLFLT cap_extent, cap_extent_mm;
1553 PLFLT cap_angle = 45.;
1558 PLFLT cap_ratio = 0.5 / tan(
PI / 360. * cap_angle );
1561 PLFLT aspspp = ( ( plsc->sppxma - plsc->sppxmi ) / plsc->xpmm ) /
1562 ( ( plsc->sppyma - plsc->sppymi ) / plsc->ypmm );
1565 PLFLT min_color, max_color;
1568 PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save;
1571 PLFLT xdmin_save = 0.0, xdmax_save = 0.0, ydmin_save = 0.0, ydmax_save = 0.0;
1575 PLFLT xdmin_adopted = 0.0, xdmax_adopted = 0.0, ydmin_adopted = 0.0, ydmax_adopted = 0.0;
1578 PLINT col0_save = plsc->icol0,
1579 line_style_save = plsc->line_style;
1582 PLFLT plot_x_subpage_bb, plot_y_subpage_bb;
1589 PLFLT colorbar_width, colorbar_height,
1590 colorbar_width_d, colorbar_height_d,
1591 colorbar_width_l, colorbar_height_l;
1597 PLFLT colorbar_width_ac, colorbar_height_ac,
1598 colorbar_width_mm, colorbar_height_mm;
1604 PLFLT dx_subpage_omd, dy_subpage_omd, dx_subpage_dml, dy_subpage_dml;
1605 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;
1608 PLFLT plot_x_subpage, plot_y_subpage;
1611 PLFLT vx_min = 0.0, vx_max = 0.0, vy_min = 0.0, vy_max = 0.0;
1614 PLFLT wx_min = 0.0, wx_max = 0.0, wy_min = 0.0, wy_max = 0.0;
1620 PLINT i, j, ni = 0, nj = 0, n_steps;
1624 PLBOOL if_edge_b = 0, if_edge_c = 0, if_edge_u = 0, if_edge_w = 0;
1628 PLFLT spxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi );
1629 PLFLT spypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi );
1632 PLFLT label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax;
1639 else if ( ( position & PL_POSITION_RIGHT ) && ( position &
PL_POSITION_LEFT ) )
1641 plabort(
"plcolorbar: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." );
1647 plabort(
"plcolorbar: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." );
1655 else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) )
1657 plabort(
"plcolorbar: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." );
1665 else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) )
1667 plabort(
"plcolorbar: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." );
1672 if ( n_labels > 0 && ( label_opts == NULL || labels == NULL ) )
1674 plabort(
"plcolorbar: label_opts and labels arrays must be defined when n_labels > 0." );
1680 plabort(
"plcolorbar: At least one axis must be specified" );
1687 plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save );
1690 if ( position & PL_POSITION_SUBPAGE )
1691 plvpor( 0., 1., 0., 1. );
1700 plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted );
1704 plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save );
1718 for ( i = 0; i < n_axes; i++ )
1720 if_edge_b = if_edge_b ||
plP_stsearch( axis_opts[i],
'b' );
1721 if_edge_c = if_edge_c ||
plP_stsearch( axis_opts[i],
'c' );
1722 if_edge_u = if_edge_u ||
plP_stsearch( axis_opts[i],
'u' );
1723 if_edge_w = if_edge_w ||
plP_stsearch( axis_opts[i],
'w' );
1725 if_edge = if_edge_b && if_edge_c && !( if_edge_u || if_edge_w );
1736 colorbar_width_d = colorbar_width;
1737 colorbar_height_d = colorbar_height;
1738 colorbar_width_mm = colorbar_width / spxpmm;
1739 colorbar_height_mm = colorbar_height / spypmm;
1744 cap_extent = cap_ratio * colorbar_height / aspspp;
1745 cap_extent_mm = cap_extent / spxpmm;
1749 cap_extent = cap_ratio * colorbar_width * aspspp;
1750 cap_extent_mm = cap_extent / spypmm;
1753 for ( i = n_axes - 1; i >= 0; i-- )
1755 min_value = values[i][0];
1756 max_value = values[i][ n_values[i] - 1 ];
1757 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
1775 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1782 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1791 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1798 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1799 plwind( wx_min, wx_max, wy_min, wy_max );
1804 ticks[i], sub_ticks[i], n_values[i], values[i] );
1806 if ( i == n_axes - 1 )
1810 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1811 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1812 if ( opt & PL_COLORBAR_ORIENT_TOP )
1813 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1814 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1815 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1816 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1817 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1821 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1822 plsc->boxbb_xmax =
MAX( plsc->boxbb_xmax, colorbar_width_mm + cap_extent_mm );
1823 if ( opt & PL_COLORBAR_ORIENT_TOP )
1824 plsc->boxbb_ymax =
MAX( plsc->boxbb_ymax, colorbar_height_mm + cap_extent_mm );
1825 if ( opt & PL_COLORBAR_ORIENT_LEFT )
1826 plsc->boxbb_xmin =
MIN( plsc->boxbb_xmin, -cap_extent_mm );
1827 if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1828 plsc->boxbb_ymin =
MIN( plsc->boxbb_ymin, -cap_extent_mm );
1834 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1836 &colorbar_width_d, &colorbar_height_d,
1837 &colorbar_width_ac, &colorbar_height_ac,
1838 &plot_x_subpage_bb, &plot_y_subpage_bb,
1839 &dx_subpage_omd, &dy_subpage_omd );
1844 plvpor( 0., colorbar_width_d, 0., colorbar_height_d );
1846 dx_subpage_omd_accu += dx_subpage_omd;
1847 dy_subpage_omd_accu += dy_subpage_omd;
1851 colorbar_width_l = colorbar_width_d;
1852 colorbar_height_l = colorbar_height_d;
1854 for ( i = 0; i < n_labels; i++ )
1860 plvpor( 0., colorbar_width_l, 0., colorbar_height_l );
1861 plwind( wx_min, wx_max, wy_min, wy_max );
1868 xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted,
1870 &colorbar_width_l, &colorbar_height_l,
1871 &colorbar_width_ac, &colorbar_height_ac,
1872 &plot_x_subpage_bb, &plot_y_subpage_bb,
1873 &dx_subpage_dml, &dy_subpage_dml );
1875 dx_subpage_dml_accu += dx_subpage_dml;
1876 dy_subpage_dml_accu += dy_subpage_dml;
1881 plot_x_subpage = plot_x_subpage_bb + dx_subpage_omd_accu + dx_subpage_dml_accu;
1882 plot_y_subpage = plot_y_subpage_bb + dy_subpage_omd_accu + dy_subpage_dml_accu;
1885 label_vpor_xmin = plot_x_subpage_bb + dx_subpage_dml_accu;
1886 label_vpor_xmax = label_vpor_xmin + colorbar_width_d;
1887 label_vpor_ymax = plot_y_subpage_bb + dy_subpage_dml_accu;
1888 label_vpor_ymin = label_vpor_ymax - colorbar_height_d;
1892 *p_colorbar_width = colorbar_width_ac;
1893 *p_colorbar_height = colorbar_height_ac;
1899 vx_min = plot_x_subpage;
1900 vx_max = plot_x_subpage + colorbar_width;
1901 vy_min = plot_y_subpage - colorbar_height;
1902 vy_max = plot_y_subpage;
1906 vx_min = plot_x_subpage;
1907 vx_max = plot_x_subpage + colorbar_width;
1908 vy_min = plot_y_subpage - colorbar_height;
1909 vy_max = plot_y_subpage;
1911 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
1913 vx_min = plot_x_subpage;
1914 vx_max = plot_x_subpage + colorbar_width;
1915 vy_min = plot_y_subpage - colorbar_height;
1916 vy_max = plot_y_subpage;
1918 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
1920 vx_min = plot_x_subpage;
1921 vx_max = plot_x_subpage + colorbar_width;
1922 vy_min = plot_y_subpage - colorbar_height;
1923 vy_max = plot_y_subpage;
1927 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
1931 plvpor( 0., 1., 0., 1. );
1932 plwind( 0., 1., 0., 1. );
1939 plot_x_subpage_bb + colorbar_width_l,
1940 plot_x_subpage_bb + colorbar_width_l,
1944 plot_y_subpage_bb - colorbar_height_l,
1945 plot_y_subpage_bb - colorbar_height_l,
1955 plvpor( vx_min, vx_max, vy_min, vy_max );
1956 plwind( wx_min, wx_max, wy_min, wy_max );
1964 if ( n_values[0] == 2 )
1969 n_steps = plsc->ncol1;
1970 step_size = ( max_value - min_value ) / (
PLFLT) n_steps;
1971 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
1976 for ( i = 0; i < ni; i++ )
1978 for ( j = 0; j < nj; j++ )
1980 color_data[i][j] = min_value + (
PLFLT) i * step_size;
1984 else if ( opt & PL_COLORBAR_ORIENT_TOP )
1989 for ( i = 0; i < ni; i++ )
1991 for ( j = 0; j < nj; j++ )
1993 color_data[i][j] = min_value + (
PLFLT) j * step_size;
1997 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2002 for ( i = 0; i < ni; i++ )
2004 for ( j = 0; j < nj; j++ )
2006 color_data[i][j] = max_value - (
PLFLT) i * step_size;
2010 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2015 for ( i = 0; i < ni; i++ )
2017 for ( j = 0; j < nj; j++ )
2019 color_data[i][j] = max_value - (
PLFLT) j * step_size;
2025 plabort(
"plcolorbar: Invalid orientation bits" );
2031 n_steps = n_values[0];
2033 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2038 for ( i = 0; i < ni; i++ )
2040 for ( j = 0; j < nj; j++ )
2042 color_data[i][j] = values[0][i];
2046 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2051 for ( i = 0; i < ni; i++ )
2053 for ( j = 0; j < nj; j++ )
2055 color_data[i][j] = values[0][j];
2059 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2064 for ( i = 0; i < ni; i++ )
2066 for ( j = 0; j < nj; j++ )
2068 color_data[i][j] = values[0][ni - 1 - i];
2072 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2077 for ( i = 0; i < ni; i++ )
2079 for ( j = 0; j < nj; j++ )
2081 color_data[i][j] = values[0][nj - 1 - j];
2087 plabort(
"plcolorbar: Invalid side" );
2092 min_value, max_value, wx_min, wx_max, wy_min, wy_max );
2103 PLFLT grid_axis[2] = { 0.0, max_abs };
2104 n_steps = n_values[0];
2106 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2108 grid.
xg = (
PLFLT *) values[0];
2109 grid.
yg = grid_axis;
2115 for ( i = 0; i < ni; i++ )
2117 for ( j = 0; j < nj; j++ )
2119 color_data[i][j] = values[0][i];
2123 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2125 grid.
xg = grid_axis;
2126 grid.
yg = (
PLFLT *) values[0];
2132 for ( i = 0; i < ni; i++ )
2134 for ( j = 0; j < nj; j++ )
2136 color_data[i][j] = values[0][j];
2140 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2142 grid.
xg = (
PLFLT *) values[0];
2143 grid.
yg = grid_axis;
2149 for ( i = 0; i < ni; i++ )
2151 for ( j = 0; j < nj; j++ )
2153 color_data[i][j] = values[0][ni - 1 - i];
2157 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2159 grid.
xg = grid_axis;
2160 grid.
yg = (
PLFLT *) values[0];
2166 for ( i = 0; i < ni; i++ )
2168 for ( j = 0; j < nj; j++ )
2170 color_data[i][j] = values[0][nj - 1 - j];
2176 plabort(
"plcolorbar: Invalid orientation" );
2181 values[0], n_steps, 0, cont_color, cont_width,
plfill,
TRUE,
2182 pltr1, (
void *) ( &grid ) );
2198 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2202 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2206 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2210 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2216 plabort(
"plcolorbar: Invalid orientation" );
2222 plabort(
"plcolorbar: One of PL_COLORBAR_IMAGE, PL_COLORBAR_SHADE, or PL_COLORBAR_GRADIENT bits must be set in opt" );
2231 plvpor( 0., 1., 0., 1. );
2232 plwind( 0., 1., 0., 1. );
2237 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2238 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2239 plot_x_subpage - cap_extent, plot_x_subpage,
2240 plot_y_subpage - colorbar_height, plot_y_subpage,
2242 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2243 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2244 plot_x_subpage, plot_x_subpage + colorbar_width,
2245 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2247 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2248 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2249 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2250 plot_y_subpage - colorbar_height, plot_y_subpage,
2252 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2253 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2254 plot_x_subpage, plot_x_subpage + colorbar_width,
2255 plot_y_subpage, plot_y_subpage + cap_extent,
2261 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2262 draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT,
2263 plot_x_subpage + colorbar_width, plot_x_subpage + colorbar_width + cap_extent,
2264 plot_y_subpage - colorbar_height, plot_y_subpage,
2266 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2267 draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP,
2268 plot_x_subpage, plot_x_subpage + colorbar_width,
2269 plot_y_subpage, plot_y_subpage + cap_extent,
2271 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2272 draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT,
2273 plot_x_subpage - cap_extent, plot_x_subpage,
2274 plot_y_subpage - colorbar_height, plot_y_subpage,
2276 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2277 draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM,
2278 plot_x_subpage, plot_x_subpage + colorbar_width,
2279 plot_y_subpage - colorbar_height - cap_extent, plot_y_subpage - colorbar_height,
2283 for ( i = n_axes - 1; i >= 0; i-- )
2285 min_value = values[i][0];
2286 max_value = values[i][ n_values[i] - 1 ];
2287 max_abs =
MAX( fabs( min_value ), fabs( max_value ) );
2291 if ( opt & PL_COLORBAR_ORIENT_RIGHT )
2298 else if ( opt & PL_COLORBAR_ORIENT_TOP )
2305 else if ( opt & PL_COLORBAR_ORIENT_LEFT )
2312 else if ( opt & PL_COLORBAR_ORIENT_BOTTOM )
2321 plabort(
"plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" );
2325 plvpor( vx_min, vx_max, vy_min, vy_max );
2326 plwind( wx_min, wx_max, wy_min, wy_max );
2331 ticks[i], sub_ticks[i], n_values[i], values[i] );
2335 plvpor( 0., 1., 0., 1. );
2336 plwind( 0., 1., 0., 1. );
2343 plot_x_subpage_bb + colorbar_width_l,
2344 plot_x_subpage_bb + colorbar_width_l,
2349 plot_y_subpage_bb - colorbar_height_l,
2350 plot_y_subpage_bb - colorbar_height_l,
2358 pllsty( line_style_save );
2363 plvpor( label_vpor_xmin, label_vpor_xmax, label_vpor_ymin, label_vpor_ymax );
2364 for ( i = 0; i < n_labels; i++ )
2371 plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save );
2372 plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save );
void plexit(PLCHAR_VECTOR errormsg)
#define PL_COLORBAR_LABEL_TOP
const PLFLT *const * PLFLT_MATRIX
#define PL_POSITION_BOTTOM
#define PL_LEGEND_BACKGROUND
const char * PLCHAR_VECTOR
#define PL_COLORBAR_ORIENT_TOP
static void plgvpsp(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)
#define PL_COLORBAR_BACKGROUND
PLBOOL plP_stsearch(PLCHAR_VECTOR str, int chr)
const char *const * PLCHAR_MATRIX
static PLFLT get_character_or_symbol_height(PLBOOL ifcharacter)
void plabort(PLCHAR_VECTOR errormsg)
#define PL_COLORBAR_SHADE
static void remove_characters(char *string, PLCHAR_VECTOR characters)
static void get_subpage_per_mm(PLFLT *x_subpage_per_mm, PLFLT *y_subpage_per_mm)
PLFLT plstrl(PLCHAR_VECTOR string)
#define PL_LEGEND_BOUNDING_BOX
void c_pllegend(PLFLT *p_legend_width, PLFLT *p_legend_height, PLINT opt, PLINT position, PLFLT x, PLFLT y, PLFLT plot_width, PLINT bg_color, PLINT bb_color, PLINT bb_style, PLINT nrow, PLINT ncolumn, PLINT nlegend, PLINT_VECTOR opt_array, PLFLT text_offset, PLFLT text_scale, PLFLT text_spacing, PLFLT text_justification, PLINT_VECTOR text_colors, PLCHAR_MATRIX text, PLINT_VECTOR box_colors, PLINT_VECTOR box_patterns, PLFLT_VECTOR box_scales, PLFLT_VECTOR box_line_widths, PLINT_VECTOR line_colors, PLINT_VECTOR line_styles, PLFLT_VECTOR line_widths, PLINT_VECTOR symbol_colors, PLFLT_VECTOR symbol_scales, PLINT_VECTOR symbol_numbers, PLCHAR_MATRIX symbols)
static void draw_label(PLBOOL if_bb, PLINT opt, PLCHAR_VECTOR label)
#define PL_POSITION_OUTSIDE
#define PL_POSITION_RIGHT
#define PL_COLORBAR_LABEL_LEFT
#define PL_LEGEND_ROW_MAJOR
#define PL_COLORBAR_SHADE_LABEL
#define PL_COLORBAR_ORIENT_BOTTOM
#define PL_POSITION_VIEWPORT
static void calculate_limits(PLINT position, PLFLT x, PLFLT y, PLFLT xdmin_adopted, PLFLT xdmax_adopted, PLFLT ydmin_adopted, PLFLT ydmax_adopted, PLFLT prior_bb_height, PLFLT *p_colorbar_width_bb, PLFLT *p_colorbar_height_bb, PLFLT *p_colorbar_width_ac, PLFLT *p_colorbar_height_ac, PLFLT *p_plot_x_subpage_bb, PLFLT *p_plot_y_subpage_bb, PLFLT *p_dx_subpage, PLFLT *p_dy_subpage)
#define subpage_to_adopted_x(nx)
#define PL_COLORBAR_GRADIENT
void plFree2dGrid(PLFLT **f, PLINT nx, PLINT PL_UNUSED(ny))
#define adopted_to_subpage_y(ny)
#define PL_POSITION_SUBPAGE
static void legend_position(PLINT position, PLFLT legend_width, PLFLT legend_height, PLFLT *x_legend_position, PLFLT *y_legend_position, PLFLT *xsign, PLFLT *ysign)
#define PL_COLORBAR_ORIENT_LEFT
const PLINT * PLINT_VECTOR
void label_box_custom(PLCHAR_VECTOR xopt, PLINT n_xticks, PLFLT_VECTOR xticks, PLCHAR_VECTOR yopt, PLINT n_yticks, PLFLT_VECTOR yticks)
#define PL_POSITION_INSIDE
void c_plcolorbar(PLFLT *p_colorbar_width, PLFLT *p_colorbar_height, PLINT opt, PLINT position, PLFLT x, PLFLT y, PLFLT x_length, PLFLT y_length, PLINT bg_color, PLINT bb_color, PLINT bb_style, PLFLT low_cap_color, PLFLT high_cap_color, PLINT cont_color, PLFLT cont_width, PLINT n_labels, PLINT_VECTOR label_opts, PLCHAR_MATRIX labels, PLINT n_axes, PLCHAR_MATRIX axis_opts, PLFLT_VECTOR ticks, PLINT_VECTOR sub_ticks, PLINT_VECTOR n_values, PLFLT_MATRIX values)
#define PL_COLORBAR_CAP_HIGH
#define PL_COLORBAR_ORIENT_RIGHT
#define PL_LEGEND_TEXT_LEFT
static void draw_cap(PLBOOL if_edge, PLINT orientation, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT color)
void plAlloc2dGrid(PLFLT ***f, PLINT nx, PLINT ny)
#define subpage_to_adopted_y(ny)
#define PL_COLORBAR_CAP_LOW
#define adopted_to_subpage_x(nx)
static void draw_box(PLBOOL if_bb, PLINT opt, PLCHAR_VECTOR axis_opts, PLBOOL if_edge, PLFLT ticks, PLINT sub_ticks, PLINT n_values, PLFLT_VECTOR values)
#define PL_LEGEND_COLOR_BOX
#define PL_COLORBAR_LABEL_BOTTOM
#define PL_COLORBAR_BOUNDING_BOX
const PLFLT * PLFLT_VECTOR
#define PL_COLORBAR_IMAGE
#define PL_COLORBAR_LABEL_RIGHT