|
From: <and...@us...> - 2013-06-06 21:32:52
|
Revision: 12371
http://sourceforge.net/p/plplot/code/12371
Author: andrewross
Date: 2013-06-06 21:32:48 +0000 (Thu, 06 Jun 2013)
Log Message:
-----------
Commit patch from Steve Schwartz to fix several bugs in placement of exponential labels.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-06-06 20:05:05 UTC (rev 12370)
+++ trunk/src/plbox.c 2013-06-06 21:32:48 UTC (rev 12371)
@@ -1776,64 +1776,89 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- else
- {
- offset = 0.02;
- height = 2.0;
- // Left axis exponent
- if ( lny )
- {
- pos = 0.0 - offset;
- just = 1.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent
+ if ( lny )
+ {
+ if (!plsc->label_data)
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "l", height, pos, just, string );
+ }
+ }
+ }
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
}
- // Right axis exponent.
- if ( lmy )
- {
- pos = 1.0 + offset;
- just = 0.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
- }
}
}
}
@@ -2307,63 +2332,88 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- else
- {
- offset = 0.02;
- height = 2.0;
- // Left axis exponent.
- if ( lny )
- {
- pos = 0.0 - offset;
- just = 1.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent.
+ if ( lny )
+ {
+ if (!plsc->label_data)
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "l", height, pos, just, string );
}
- else
- {
- plmtex( "t", height, pos, just, string );
- }
}
- // Right axis exponent.
- if ( lmy )
- {
- pos = 1.0 + offset;
- just = 0.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
+ }
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|