|
From: Ethan M. <merritt@u.washington.edu> - 2009-08-31 19:36:46
|
On Monday 31 August 2009 11:26:16 Benjamin Lindner wrote:
> Hello list,
>
> I came across a (for me) strange behaviour, which is, that if you use
> the "labels" plotstyle increases the linestyle, although no line is drawn.
That is entirely expected, but only if you realize that "linestyle" and
"linetype" have evolved into misnomers. The linestyle or linetype is
described by a structure that specifies far more than just the color.
From term_api.h:
typedef struct lp_style_type { /* contains all Line and Point properties */
int pointflag; /* 0 if points not used, otherwise 1 */
int l_type;
int p_type;
int p_interval; /* Every Nth point in style LINESPOINTS */
double l_width;
double p_size;
TBOOLEAN use_palette;
struct t_colorspec pm3d_color;
/* ... more to come ? */
} lp_style_type;
The thing is, these properties affect points just as much as they affect
lines per se. You still have to draw the point with some linewidth and
some color, right? For that matter, what about plots "with linespoints"
where the same set of properties applies to both the lines and the points.
Which brings us to labels...
One of the properties of a label is {{no}point}, which controls whether or
not a point is drawn exactly at the coordinates given. If you select to
have a point drawn for each label, the point properties have to come from
somewhere and the obvious place is to take them from the "linestyle" of the
current plot.
So, for example, you might draw a plot containing many labeled data sets,
and distinguish which point is from which dataset by the color/shape of the
associated points. Make sense?
set style data labels
plot '1.dat' point pt 5, '2.dat' point pt 7, '3.dat' point pt 1
That will give you a plot containing three sets of labeled points.
All the labels will be in the normal (black) font since we haven't done
anything special to do otherwise. Some will be marked by red squares,
some by green circles, and some by blue crosses.
> I am using a 4.3.0 CVS snapshot version.
>
> Test case:
> set style data linespoints
>
> set style line 1 lt 1 lc rgb "red"
> set style line 2 lt 1 lc rgb "green"
> set style line 3 lt 1 lc rgb "blue"
>
> set label 1 "lines should be red and green" at graph 0.5, 0.9
>
> set style increment user
>
> plot '-' u 0:1, '-' u 0:1:1 with labels offset character 0,1,0 , '-' u 0:1
> 1
> 2
> 3
> 4
> 5
> e
> 1
> 2
> 3
> 4
> 5
> e
> 2
> 3
> 4
> 5
> 6
> e
>
> I would expect the lines to have color red and green, not red and blue.
>
> I looked at the source code in src/plot2d.c and found that for certain
> plotstyles this increase of the line style is disabled. However, not for
> the "labels" plotstyle.
> Is this deliberate?
> May I suggest the following change:
>
> diff -r d67b4d3fbb86 src/plot2d.c
> --- a/src/plot2d.c Mon Aug 31 09:08:58 2009 +0200
> +++ b/src/plot2d.c Mon Aug 31 09:09:17 2009 +0200
> @@ -1975,8 +1975,9 @@
> && this_plot->plot_style != IMAGE
> && this_plot->plot_style != RGBIMAGE
> && this_plot->plot_style != RGBA_IMAGE
> + && this_plot->plot_style != LABELPOINTS
> /* don't increment the default line/point properties if
> - * this_plot is an image */
> + * this_plot is an image or labels plot */
> ) {
> if (this_plot->plot_style & PLOT_STYLE_HAS_POINT)
> ++point_num;
>
>
> benjamin
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|