|
From: <jun...@so...> - 2006-04-07 17:34:56
|
The ratio-corrected box is seemed be centerd on the page. This change looks good for ploting just one graph, but it becomses practically impossible to put some ratio-corrected graphs on the positions which I want. Thus, I made some patches to controll this centering behavior by using the sign of the ysize. There may be some problem, but please check. Jun *** gadgets.c.org Sat Apr 8 02:20:01 2006 --- gadgets.c Sat Apr 8 02:21:02 2006 *************** *** 75,80 **** --- 75,81 ---- float xoffset = 0.0; /* x origin */ float yoffset = 0.0; /* y origin */ float aspect_ratio = 0.0; /* don't attempt to force it */ + TBOOLEAN centering_in_ratio = TRUE; /* centering in ratio plot */ /* space between left edge and plot_bounds.xleft in chars (-1: computed) */ float lmargin = -1; *** gadgets.h.org Sat Apr 8 02:21:51 2006 --- gadgets.h Sat Apr 8 02:22:12 2006 *************** *** 304,310 **** extern float xoffset; /* x origin setting */ extern float yoffset; /* y origin setting */ extern float aspect_ratio; /* 1.0 for square */ ! /* plot border autosizing overrides, in characters (-1: autosize) */ extern float lmargin, bmargin, rmargin, tmargin; --- 304,310 ---- extern float xoffset; /* x origin setting */ extern float yoffset; /* y origin setting */ extern float aspect_ratio; /* 1.0 for square */ ! extern TBOOLEAN centering_in_ratio; /* TRUE */ /* plot border autosizing overrides, in characters (-1: autosize) */ extern float lmargin, bmargin, rmargin, tmargin; *** set.c.org Sat Apr 8 02:20:08 2006 --- set.c Sat Apr 8 02:21:15 2006 *************** *** 3468,3476 **** } } } ! if (xsize <= 0 || ysize <=0) { xsize = ysize = 1.0; int_error(NO_CARET,"Illegal value for size"); } } --- 3468,3485 ---- } } } ! if ((aspect_ratio ==0.0) && (xsize <= 0 || ysize <=0)) { xsize = ysize = 1.0; int_error(NO_CARET,"Illegal value for size"); + } else if ( xsize == 0.0 || ysize == 0.0 ) { + xsize = ysize = 1.0; + centering_in_ratio = TRUE; + int_error(NO_CARET,"Illegal value for size"); + } else if ( ysize > 0 ) { + centering_in_ratio = TRUE; + } else if ( ysize < 0 ) { + ysize = -ysize; + centering_in_ratio = FALSE; } } *** graphics.c.org Sat Apr 8 02:20:15 2006 --- graphics.c Sat Apr 8 02:21:20 2006 *************** *** 899,910 **** --- 899,915 ---- if (current > required) { /* too tall */ + if (centering_in_ratio) { + /* centering */ int height = plot_bounds.ytop - plot_bounds.ybot; plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft); height -= (plot_bounds.ytop - plot_bounds.ybot); height /= 2; plot_bounds.ytop += height; plot_bounds.ybot += height; + } else { + plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft); + } } else { int width = plot_bounds.xright - plot_bounds.xleft; plot_bounds.xright = plot_bounds.xleft + (plot_bounds.ytop - plot_bounds.ybot) / required; |
|
From:
<br...@ph...> - 2006-04-07 18:14:41
|
jun...@so... wrote: > The ratio-corrected box is seemed be centerd on the page. > This change looks good for ploting just one graph, but it becomses > practically impossible to put some ratio-corrected graphs on the positions > which I want. That's at least 50% practically impossible anyway --- a graph with 'set size ratio' turned on changes shape outside the control of 'set size'. That's how that whole feature works. Even after you fixated its bottom left corner, its top right one can be anywhere. I don't see how changing half the problem is of any help. It would be just as easy to adjust the main 'size' parameters manually, such that the difference between left-justified and centered position of the actual graph area becomes negligible. > Thus, I made some patches to controll this centering behavior > by using the sign of the ysize. I find that unacceptably obfuscated. This is basically a change to the origin and/or margin settings, not to the size of the graph. It has no business being controlled as part of 'set size' at all --- even less so being hidden in the sign of a must-be-positive parameter. |
|
From: Daniel J S. <dan...@ie...> - 2006-04-07 20:22:58
|
Hans-Bernhard Br=F6ker wrote:
> jun...@so... wrote:
>=20
>> The ratio-corrected box is seemed be centerd on the page.
>> This change looks good for ploting just one graph, but it becomses
>> practically impossible to put some ratio-corrected graphs on the=20
>> positions
>> which I want.=20
>=20
>=20
> That's at least 50% practically impossible anyway --- a graph with 'set=
=20
> size ratio' turned on changes shape outside the control of 'set size'.
> That's how that whole feature works. Even after you fixated its
> bottom left corner, its top right one can be anywhere. I don't see how=
=20
> changing half the problem is of any help. It would be just as easy to
> adjust the main 'size' parameters manually, such that the difference=20
> between left-justified and centered position of the actual graph area=20
> becomes negligible.
>=20
> > Thus, I made some patches to controll this centering behavior
>=20
>> by using the sign of the ysize.
>=20
>=20
> I find that unacceptably obfuscated. This is basically a change to
> the origin and/or margin settings, not to the size of the graph. It ha=
s=20
> no business being controlled as part of 'set size' at all --- even less=
=20
> so being hidden in the sign of a must-be-positive parameter.
The two of us seem to agree on negative parameters. Even the existing sy=
ntax:
Syntax:
set size {{no}square | ratio <r> | noratio} {<xscale>,<yscale>}
show size
...
The meaning of a negative value for <r> is different. If <r>=3D-1, gnup=
lot
tries to set the scales so that the unit has the same length on both the=
x
and y axes (suitable for geographical data, for instance). If <r>=3D-2,=
the
unit on y has twice the length of the unit on x, and so on.
seems a bit obfuscating, and probably why Jun thought to use negative num=
bers for the scale. Even square/nosquare/ratio/noratio isn't the most ob=
vious thing. There is an implication that square and ratio are active at=
the same time. Is that the case.
What I mean is that if there is a "no" associated with a parameter, it is=
implied in a sense that said parameter is independent from other paramet=
er, i.e., it can be turned on and off. If there is a "nosquare" and a "n=
oratio", does that mean than can both be on at the same time? Or is "nos=
quare" and alias for "noratio".
Maybe a syntax like:
set size {auto | square | ratio {plot|unit} <r>} {<xscale>,<yscale=
>}
or something similar would be more appropriate.
Dan
|
|
From: Daniel J S. <dan...@ie...> - 2006-04-07 20:29:59
|
Lots of typos in last email (crumps): > active at the same time. Is that the case. ? (not .) > parameter, i.e., it can be turned on and off. If there is a "nosquare" "parameters" > and a "noratio", does that mean than can both be on at the same time? "they can both" > Or is "nosquare" and alias for "noratio". "an alias" |
|
From: <jun...@so...> - 2006-04-08 19:05:17
|
How about the syntax below?
set size {{no}squre | ratio { center | xaxis | yaxis } <r> | noratio } {<xscale>,<yscale>}
The option "center" is default behavior same as the present.
In the option "x(y)axis", <y(x)scale> is neglected and a graph boundary
is calculated with the reference to only the length of the x(y)-axis.
Then, y(x)scale is calculated by the graph boundary and reset.
This option should resolve all the problem in multiplot,
since we can fixate the bottom left corner and know the position of
the right top one.
Patches below are just my idea and there should be more appropriate
methods to implement.
Those two feature must be very useful to put several graphs of
the same ratio and the same length of the axis in multiplot.
So, I hope such features are implemented in future gnuplot by any way.
*** gadgets.h.org Sun Apr 9 03:49:05 2006
--- gadgets.h Sun Apr 9 03:49:14 2006
***************
*** 305,310 ****
--- 305,318 ----
extern float yoffset; /* y origin setting */
extern float aspect_ratio; /* 1.0 for square */
+ /* graph position in set size ratio plot */
+ typedef enum ratio_position_type {
+ CENTER,
+ XAXIS,
+ YAXIS
+ } ratio_position_type;
+ extern enum ratio_position_type ratioposition; /* CENTER */
+
/* plot border autosizing overrides, in characters (-1: autosize) */
extern float lmargin, bmargin, rmargin, tmargin;
*** gadgets.c.org Sun Apr 9 03:47:55 2006
--- gadgets.c Sun Apr 9 03:48:17 2006
***************
*** 75,80 ****
--- 75,81 ----
float xoffset = 0.0; /* x origin */
float yoffset = 0.0; /* y origin */
float aspect_ratio = 0.0; /* don't attempt to force it */
+ enum ratio_position_type ratioposition = CENTER; /* graph position in ratio plot */
/* space between left edge and plot_bounds.xleft in chars (-1: computed) */
float lmargin = -1;
*** set.c.org Sun Apr 9 03:49:43 2006
--- set.c Sun Apr 9 03:50:14 2006
***************
*** 3452,3457 ****
--- 3452,3467 ----
++c_token;
} else if (almost_equals(c_token,"ra$tio")) {
++c_token;
+ if (almost_equals(c_token,"cen$ter")) {
+ ++c_token;
+ ratioposition = CENTER;
+ } else if (almost_equals(c_token,"x$axis")) {
+ ++c_token;
+ ratioposition = XAXIS;
+ } else if (almost_equals(c_token,"y$axis")) {
+ ++c_token;
+ ratioposition = YAXIS;
+ }
aspect_ratio = real(const_express(&s));
} else if (almost_equals(c_token, "nora$tio") || almost_equals(c_token, "nosq$uare")) {
aspect_ratio = 0.0;
*** graphics.c.org Sun Apr 9 03:49:52 2006
--- graphics.c Sun Apr 9 03:55:36 2006
***************
*** 319,324 ****
--- 319,326 ----
int xtic_height;
int ytic_width;
int y2tic_width;
+ int top_margin; /* calculated top margin */
+ int right_margin; /* calculated right margin */
int key_cols = 1; /* # columns of keys */
***************
*** 444,450 ****
plot_bounds.ytop = (int) (0.5 + (ysize + yoffset) * t->ymax);
if (tmargin < 0) {
! int top_margin = x2label_textheight + title_textheight;
if (timetop_textheight + ylabel_textheight > top_margin)
top_margin = timetop_textheight + ylabel_textheight;
--- 446,452 ----
plot_bounds.ytop = (int) (0.5 + (ysize + yoffset) * t->ymax);
if (tmargin < 0) {
! top_margin = x2label_textheight + title_textheight;
if (timetop_textheight + ylabel_textheight > top_margin)
top_margin = timetop_textheight + ylabel_textheight;
***************
*** 461,466 ****
--- 463,469 ----
plot_bounds.ytop -= top_margin;
if (plot_bounds.ytop == (int) (0.5 + (ysize + yoffset) * t->ymax)) {
/* make room for the end of rotated ytics or y2tics */
+ top_margin += (int) (t->h_char * 2);
plot_bounds.ytop -= (int) (t->h_char * 2);
}
} else
***************
*** 849,865 ****
if (rmargin < 0) {
/* plot_bounds.xright -= y2label_textwidth + y2tic_width + y2tic_textwidth; */
! plot_bounds.xright -= y2tic_width + y2tic_textwidth;
if (y2label_textwidth > 0)
! plot_bounds.xright -= y2label_textwidth;
!
if (plot_bounds.xright == (int) (0.5 + t->xmax * (xsize + xoffset))) {
/* make room for end of xtic or x2tic label */
plot_bounds.xright -= (int) (t->h_char * 2);
}
/* DBT 12-3-98 extra margin just in case */
plot_bounds.xright -= 0.5 * t->v_char;
-
} else
plot_bounds.xright -= (int) (rmargin * t->h_char);
--- 852,869 ----
if (rmargin < 0) {
/* plot_bounds.xright -= y2label_textwidth + y2tic_width + y2tic_textwidth; */
! right_margin = y2tic_width + y2tic_textwidth;
if (y2label_textwidth > 0)
! right_margin += y2label_textwidth;
! plot_bounds.xright -= right_margin;
if (plot_bounds.xright == (int) (0.5 + t->xmax * (xsize + xoffset))) {
/* make room for end of xtic or x2tic label */
+ right_margin += (int) (t->h_char * 2);
plot_bounds.xright -= (int) (t->h_char * 2);
}
/* DBT 12-3-98 extra margin just in case */
+ right_margin += 0.5 * t->v_char;
plot_bounds.xright -= 0.5 * t->v_char;
} else
plot_bounds.xright -= (int) (rmargin * t->h_char);
***************
*** 896,904 ****
if (current_aspect_ratio >= 0.01 && current_aspect_ratio <= 100.0) {
double current = ((double) (plot_bounds.ytop - plot_bounds.ybot)) / (plot_bounds.xright - plot_bounds.xleft);
double required = (current_aspect_ratio * t->v_tic) / t->h_tic;
!
! if (current > required) {
! /* too tall */
int height = plot_bounds.ytop - plot_bounds.ybot;
plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft);
height -= (plot_bounds.ytop - plot_bounds.ybot);
--- 900,909 ----
if (current_aspect_ratio >= 0.01 && current_aspect_ratio <= 100.0) {
double current = ((double) (plot_bounds.ytop - plot_bounds.ybot)) / (plot_bounds.xright - plot_bounds.xleft);
double required = (current_aspect_ratio * t->v_tic) / t->h_tic;
! /* CENTER */
! if (ratioposition == CENTER ) {
! if (current > required) {
! /* too tall */
int height = plot_bounds.ytop - plot_bounds.ybot;
plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft);
height -= (plot_bounds.ytop - plot_bounds.ybot);
***************
*** 912,917 ****
--- 917,949 ----
width /= 2;
plot_bounds.xright += width;
plot_bounds.xleft += width;
+ }
+ /* XAXIS */
+ } else if (ratioposition == XAXIS ) {
+ plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft);
+ if ( fabs((current-required)/required) > 0.001 ) /* for replot */
+ { /* calculate ysize */
+ if(tmargin<0) {
+ ysize = ((double) (plot_bounds.ytop + top_margin)) / ((double) (t->ymax)) + yoffset;
+ fprintf(stderr, "\tsize is set to %g,%g\n", xsize, ysize);
+ } else {
+ ysize = ((double) (plot_bounds.ytop + tmargin * t->v_char)) / ((double) (t->ymax)) + yoffset;
+ fprintf(stderr, "\tsize is set to %g,%g\n", xsize, ysize);
+ }
+ }
+ /* YAXIS */
+ } else if (ratioposition == YAXIS ) {
+ plot_bounds.xright = plot_bounds.xleft + (plot_bounds.ytop - plot_bounds.ybot) / required ;
+ if ( fabs((current-required)/required) > 0.001 ) /* for replot */
+ { /* calculate xsize */
+ if(rmargin<0) {
+ xsize = ((double) (plot_bounds.xright + right_margin)) / ((double) (t->xmax)) + xoffset;
+ fprintf(stderr, "\tsize is set to %g,%g\n", xsize, ysize);
+ } else {
+ xsize = ((double) (plot_bounds.xright + rmargin * t->h_char)) / ((double) (t->xmax)) + xoffset;
+ fprintf(stderr, "\tsize is set to %g,%g\n", xsize, ysize);
+ }
+ }
}
}
/*}}} */
|
|
From:
<br...@ph...> - 2006-04-09 12:08:49
|
jun...@so... wrote:
> How about the syntax below?
>
> set size {{no}squre | ratio { center | xaxis | yaxis } <r> | noratio } {<xscale>,<yscale>}
No better, arguably even worse then the previous proposal. As I said
before, controlling this aspect of the positioning has no business being
in "set size" in the first place, simply because it doesn't change the
size at all. It changes the origin. So it should go into 'set origin'.
And it'll need positioning options along the lines those of 'set key',
'left', 'right', 'top', 'bottom', ....
|
|
From: Daniel J S. <dan...@ie...> - 2006-04-07 18:27:12
|
jun...@so... wrote: > The ratio-corrected box is seemed be centerd on the page. > This change looks good for ploting just one graph, but it becomses > practically impossible to put some ratio-corrected graphs on the positions > which I want. Thus, I made some patches to controll this centering behavior > by using the sign of the ysize. > > There may be some problem, but please check. > > Jun Thanks for bringing this to attention, Jun. This centering sounds like something I changed. I may well have overlooked the case where the user wants to manually position a ratio corrected plot. However, I'm not so sure adding meaning to a negative size value is the way to address this. (Don't know how others feel about this, but I prefer simply adding another option if necessary.) It seems to me that centering should simply be the default and if the user specifies a position then move the plot to that position. Is there an alternative syntax to accomplish this? Dan |