🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.graphics.apps.gnuplot
1 messages
1 total messages Started by u600256@rho.lanl Thu, 29 Aug 1996 00:00
"set key" -- vertical spacing patch
#4047
Author: u600256@rho.lanl
Date: Thu, 29 Aug 1996 00:00
406 lines
14368 bytes
Hi, gang,

I finally had a chance to code a quick-and-dirty option for selecting the
vertical line spacing in the key.  I patched my previous sample length mod
into v301 and then added the vertical spacing mod.  Thus the attached patch
contains both.  If you've already applied the older patch, it shouldn't be
hard to disentangle the two.

Here are the combined changes to 'set key':

1) There are two new options: "samplen" (for "sample length"), which requires
an integer argument; and "spacing", which requires a real argument.  These go
between the "reverse" and "title" options on the command, so the syntax for
"set key" is now

         set key { <position> | \
                   left | right | top | bottom | outside | below } \
                 { Left | Right } { {no}reverse } \
                 { samplen <sample_length> } { spacing <vertical_spacing> } \
                 { title "<text>" } { {no}box {<linetype>} }

"samplen" sets (almost) the length of the sample line in the key.  The
"(almost)" is because actually gnuplot sets the sample line length to be
equal to the sum of the tic length and a multiple of the character width.
<sample_length> is the multiplier.  Its default value is 4.  Negative values
are replaced internally by zero.

Points, boxes, and the like are also affected because they are centered
on the sample line even if it is not actually drawn.

"spacing" sets the vertical line spacing equal to t*p*s, where t is the tic
size, p is the pointsize, and s is <vertical_spacing>.  The default for
<vertical_spacing> is 1.25.  (Previously the 1.25 was hard-coded, so the
change I made is pretty simple.)  Negative input values are reset to zero.


2) In 273 "set key" with no options returns the key to its default
position but leaves everything else unaltered.  The patch changes this
so that "set key" returns the key entirely to its default configuration,
i.e., noreverse, nobox, notitle, etc.  I suppose we could add "default"
as an option that would do the same thing... that would be consistent
with many (but not all) commands.


3) The code in "set.c" seemed to allow the user to abbreviate "box" by
"b".  However in practice this gets confused with "b" also being an
abbreviation for "bottom".  This patch requires that "box" be written
in full.  Hopefully two extra characters won't be too taxing...


Obviously this patch preserves constant line spacing in the key.  I would
prefer a scheme in which the spacing is variable, but this is better than
nothing.  At least I hope it is :-)


Dick Crawford, aka rccrawford@lanl.gov


==========================================================================
*** graph3d.c	Mon Jun 10 11:46:03 1996
--- new.graph3d.c	Wed Aug 28 17:38:09 1996
***************
*** 60,68 ****
  #include "plot.h"
  #include "setshow.h"
  
- 
- #define KEYWTH ( (int) (4*(t->h_char) + pointsize*(t->h_tic)))
- 
  static int p_height;
  static int p_width;  /* pointsize * t->h_tic */
  static int key_entry_height;  /* bigger of t->v_size, pointsize*t->v_tick */
--- 60,65 ----
***************
*** 171,177 ****
  static int ptitl_cnt;
  static int max_ptitl_len;
  static int titlelin;
! static int key_rows, key_cols, key_col_wth, yl_ref;
  static int ktitle_lines = 0;
  
  
--- 168,174 ----
  static int ptitl_cnt;
  static int max_ptitl_len;
  static int titlelin;
! static int key_sample_width, key_rows, key_cols, key_col_wth, yl_ref;
  static int ktitle_lines = 0;
  
  
***************
*** 377,383 ****
  
     p_height= pointsize * t->v_tic;
     p_width = pointsize * t->h_tic;
!    key_entry_height = pointsize * (t->v_tic) * 1.25;
     if (key_entry_height < (t->v_char) )
  	key_entry_height = (t->v_char);
  
--- 374,384 ----
  
     p_height= pointsize * t->v_tic;
     p_width = pointsize * t->h_tic;
!    if (key_swidth >= 0)
!         key_sample_width = key_swidth*(t->h_char) + pointsize*(t->h_tic);
!    else
!         key_sample_width = 0;
!    key_entry_height = pointsize * (t->v_tic) * key_vert_factor;
     if (key_entry_height < (t->v_char) )
  	key_entry_height = (t->v_char);
  
***************
*** 385,391 ****
     max_ptitl_len = find_maxl_keys3d(plots,count,&ptitl_cnt);
     if ( (ytlen = label_width(key_title,&ktitle_lines)) > max_ptitl_len )
  	   max_ptitl_len = ytlen;
!    key_col_wth = (max_ptitl_len + 4 ) * (t->h_char) + KEYWTH;
  
      /* luecken@udel.edu modifications
         sizes the plot to take up more of available resolution */
--- 386,392 ----
     max_ptitl_len = find_maxl_keys3d(plots,count,&ptitl_cnt);
     if ( (ytlen = label_width(key_title,&ktitle_lines)) > max_ptitl_len )
  	   max_ptitl_len = ytlen;
!    key_col_wth = (max_ptitl_len + 4 ) * (t->h_char) + key_sample_width;
  
      /* luecken@udel.edu modifications
         sizes the plot to take up more of available resolution */
***************
*** 398,404 ****
     key_cols = 1;
     if (key == -1 && key_vpos == TUNDER ) {
  	/* calculate max no cols, limited by label-length */
! 	key_cols = (int)(xright - xleft)/((max_ptitl_len + 4 ) * (t->h_char) + KEYWTH);
  	key_rows = (int)(ptitl_cnt/key_cols)+((ptitl_cnt%key_cols)>0);
  	/* now calculate actual no cols depending on no rows */
  	key_cols = (int)(ptitl_cnt/key_rows)+((ptitl_cnt%key_rows)>0); 
--- 399,405 ----
     key_cols = 1;
     if (key == -1 && key_vpos == TUNDER ) {
  	/* calculate max no cols, limited by label-length */
! 	key_cols = (int)(xright - xleft)/((max_ptitl_len + 4 ) * (t->h_char) + key_sample_width);
  	key_rows = (int)(ptitl_cnt/key_cols)+((ptitl_cnt%key_cols)>0);
  	/* now calculate actual no cols depending on no rows */
  	key_cols = (int)(ptitl_cnt/key_rows)+((ptitl_cnt%key_rows)>0); 
***************
*** 632,650 ****
  /* WORK OUT KEY SETTINGS AND DO KEY TITLE / BOX */
  
  	if (key_reverse) {
! 		key_sample_left= -KEYWTH;
  		key_sample_right= 0;
  		key_text_left=t->h_char;
  		key_text_right=(t->h_char)*(max_ptitl_len+1);
  		key_size_right=(t->h_char)*(max_ptitl_len+2);
! 		key_size_left=(t->h_char) + KEYWTH;
  	} else {
  		key_sample_left= 0;
! 		key_sample_right= KEYWTH;
  		key_text_left=-(int)((t->h_char)*(max_ptitl_len+1));
  		key_text_right=-(int)(t->h_char);
  		key_size_left=(t->h_char)*(max_ptitl_len+2);
! 		key_size_right=(t->h_char)+KEYWTH;
  	}
  	key_point_offset = (key_sample_left + key_sample_right)/2;
  
--- 633,651 ----
  /* WORK OUT KEY SETTINGS AND DO KEY TITLE / BOX */
  
  	if (key_reverse) {
!   		key_sample_left= -key_sample_width;
  		key_sample_right= 0;
  		key_text_left=t->h_char;
  		key_text_right=(t->h_char)*(max_ptitl_len+1);
  		key_size_right=(t->h_char)*(max_ptitl_len+2);
!   		key_size_left=(t->h_char) + key_sample_width;
  	} else {
  		key_sample_left= 0;
!   		key_sample_right= key_sample_width;
  		key_text_left=-(int)((t->h_char)*(max_ptitl_len+1));
  		key_text_right=-(int)(t->h_char);
  		key_size_left=(t->h_char)*(max_ptitl_len+2);
!   		key_size_right=(t->h_char)+key_sample_width;
  	}
  	key_point_offset = (key_sample_left + key_sample_right)/2;
  
***************
*** 652,658 ****
   	    if ( key_vpos == TUNDER ) {
  #if 0
  		yl = yoffset * t->ymax + (key_rows) * key_entry_height + (ktitle_lines+2)*t->v_char;
! 		xl = max_ptitl_len * 1000/( KEYWTH/(t->h_char) + max_ptitl_len + 2);
  		xl *= (xright - xleft)/key_cols;
  		xl /= 1000;
  		xl += xleft;
--- 653,659 ----
   	    if ( key_vpos == TUNDER ) {
  #if 0
  		yl = yoffset * t->ymax + (key_rows) * key_entry_height + (ktitle_lines+2)*t->v_char;
! 		xl = max_ptitl_len * 1000/( key_sample_width/(t->h_char) + max_ptitl_len + 2);
  		xl *= (xright - xleft)/key_cols;
  		xl /= 1000;
  		xl += xleft;
*** graphics.c	Mon Aug 12 13:35:56 1996
--- new.graphics.c	Wed Aug 28 17:36:41 1996
***************
*** 63,68 ****
--- 63,69 ----
   */
  
  /*{{{  local and global variables*/
+ static int key_sample_width;   /* width of line sample */
  static int key_sample_left;   /* offset from x for left of line sample */
  static int key_sample_right;  /* offset from x for right of line sample */
  static int key_point_offset;  /* offset from x for point sample */
***************
*** 441,447 ****
  		p_width  = pointsize * t->h_tic;
  		p_height = pointsize * t->v_tic;
  		
! 		key_entry_height = p_height * 1.25;
  		if (key_entry_height < (t->v_char) )
  			key_entry_height = (t->v_char);
  		
--- 442,453 ----
  		p_width  = pointsize * t->h_tic;
  		p_height = pointsize * t->v_tic;
  		
! 		if (key_swidth >= 0 )
! 			key_sample_width= key_swidth*(t->h_char) + p_width;
! 		else
! 			key_sample_width= 0;
! 
! 		key_entry_height = p_height * key_vert_factor;
  		if (key_entry_height < (t->v_char) )
  			key_entry_height = (t->v_char);
  		
***************
*** 451,457 ****
  			max_ptitl_len = ytlen;
  		
  		if (key_reverse) {
! 			key_sample_left= -4*(t->h_char) - p_width;
  			key_sample_right= 0;
  			key_text_left=t->h_char;
  			key_text_right=(t->h_char)*(max_ptitl_len+1);
--- 457,463 ----
  			max_ptitl_len = ytlen;
  		
  		if (key_reverse) {
! 			key_sample_left= -key_sample_width;
  			key_sample_right= 0;
  			key_text_left=t->h_char;
  			key_text_right=(t->h_char)*(max_ptitl_len+1);
***************
*** 460,466 ****
  			key_size_right=key_text_right + t->h_char;
  		} else {
  			key_sample_left= 0;
! 			key_sample_right= 4*(t->h_char) + p_width;
  			key_text_left = -(int)((t->h_char)*(max_ptitl_len+1));
  			key_text_right = -(int)(t->h_char);
  			key_size_left=t->h_char - key_text_left;
--- 466,472 ----
  			key_size_right=key_text_right + t->h_char;
  		} else {
  			key_sample_left= 0;
!   			key_sample_right= key_sample_width;
  			key_text_left = -(int)((t->h_char)*(max_ptitl_len+1));
  			key_text_right = -(int)(t->h_char);
  			key_size_left=t->h_char - key_text_left;
*** misc.c	Wed Aug 14 16:04:37 1996
--- new.misc.c	Wed Aug 28 17:46:06 1996
***************
*** 499,508 ****
  			break;
  	}
  	if (key) {
! 		fprintf(fp, " %s %sreverse box %d\n",
  			key_just==JLEFT ? "Left" : "Right", 
  		   key_reverse ? "" : "no",
! 		   key_box+1);
  	}
  	fprintf(fp,"set nolabel\n");
  	for (this_label = first_label; this_label != NULL;
--- 499,508 ----
  			break;
  	}
  	if (key) {
! 		fprintf(fp, " %s %sreverse box %d samplen %d spacing %g\n",
  			key_just==JLEFT ? "Left" : "Right", 
  		   key_reverse ? "" : "no",
! 		   key_box+1, key_swidth, key_vert_factor);
  	}
  	fprintf(fp,"set nolabel\n");
  	for (this_label = first_label; this_label != NULL;
*** set.c	Wed Aug 14 16:04:39 1996
--- new.set.c	Wed Aug 28 17:49:54 1996
***************
*** 122,127 ****
--- 122,129 ----
  struct position key_user_pos;	/* user specified position for key */
  TBOOLEAN		key_reverse	= FALSE;  /* reverse text & sample ? */
  int			key_box		= -3; /* no linetype */
+ int                     key_swidth      = 4;
+ double                  key_vert_factor = 1.25;
  TBOOLEAN		is_log_x	= FALSE;
  TBOOLEAN		is_log_y	= FALSE;
  TBOOLEAN		is_log_z	= FALSE;
***************
*** 539,544 ****
--- 541,548 ----
    key_just	 = JRIGHT;
    key_reverse	 = FALSE;
    key_box	 = -3;
+   key_swidth     = 4;
+   key_vert_factor = 1.25;
    datatype[FIRST_X_AXIS]	 = FALSE;
    datatype[FIRST_Y_AXIS]	 = FALSE;
    datatype[FIRST_Z_AXIS]	 = FALSE;
***************
*** 1493,1498 ****
--- 1497,1507 ----
  			key_vpos = TTOP;
  			key_hpos = TRIGHT;
  			key_just = JRIGHT;
+ 			key_reverse = FALSE;
+                         key_box = -3;
+                         key_swidth = 4;
+                         key_vert_factor = 1.25;
+ 			key_title[0]=0;
  		} 
  		else {
  			while (!END_OF_COMMAND) {
***************
*** 1530,1541 ****
  					key_reverse=TRUE;
  				} else if (almost_equals(c_token,"norev$erse")) {
  					key_reverse=FALSE;
! 				} else if (almost_equals(c_token,"b$ox")) {
  					++c_token;
  					if (END_OF_COMMAND)
  						key_box=-2;
  					else
! 						key_box=real(const_express(&a))-1;
  					--c_token;  /* is incremented after loop */
  				} else if (almost_equals(c_token,"nob$ox")) {
  					key_box=-3;
--- 1539,1558 ----
  					key_reverse=TRUE;
  				} else if (almost_equals(c_token,"norev$erse")) {
  					key_reverse=FALSE;
! 				} else if (almost_equals(c_token,"s$amplen")) {
  					++c_token;
+ 			                key_swidth = (int) real(const_express(&a));
+ 					--c_token;  /* is incremented after loop */
+ 				} else if (almost_equals(c_token,"sp$acing")) {
+ 					++c_token;
+ 			                key_vert_factor = real(const_express(&a));
                                        if(key_vert_factor < 0.0) key_vert_factor=0.0;
+ 					--c_token;  /* is incremented after loop */
+ 				} else if (almost_equals(c_token,"box$")) {
+ 					++c_token;
  					if (END_OF_COMMAND)
  						key_box=-2;
  					else
! 						key_box = (int) real(const_express(&a))-1;
  					--c_token;  /* is incremented after loop */
  				} else if (almost_equals(c_token,"nob$ox")) {
  					key_box=-3;
*** setshow.h	Wed Aug 14 16:04:41 1996
--- new.setshow.h	Wed Aug 28 17:41:34 1996
***************
*** 116,122 ****
  extern double     polar_grid_angle; /* angle step in polar grid in radians */
  extern int			key;
  extern struct position key_user_pos; /* user specified position for key */
! extern int 			key_vpos, key_hpos, key_just;
  extern TBOOLEAN			key_reverse;  /* key back to front */
  extern int			key_box;  /* linetype round box < -2 = none */
  extern TBOOLEAN			is_log_x, is_log_y, is_log_z;
--- 116,123 ----
  extern double     polar_grid_angle; /* angle step in polar grid in radians */
  extern int			key;
  extern struct position key_user_pos; /* user specified position for key */
! extern int 			key_swidth, key_vpos, key_hpos, key_just;
! extern double                   key_vert_factor; /* user specified vertical spacing multiplier */
  extern TBOOLEAN			key_reverse;  /* key back to front */
  extern int			key_box;  /* linetype round box < -2 = none */
  extern TBOOLEAN			is_log_x, is_log_y, is_log_z;
*** show.c	Wed Aug 14 16:04:42 1996
--- new.show.c	Wed Aug 28 17:44:58 1996
***************
*** 1083,1088 ****
--- 1083,1090 ----
  			fprintf(stderr, "boxed with linetype %d\n", key_box+1);
  		else
  			fprintf(stderr, "not boxed\n");
+ 	        fprintf(stderr,"\tsample length is %d characters\n",key_swidth);
+ 	        fprintf(stderr,"\tvertical spacing is %g characters\n",key_vert_factor);
  		fprintf(stderr, "\tkey title is \"%s\"\n", key_title);
  	}
  }


Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads