|
From: Ethan M. <merritt@u.washington.edu> - 2005-02-05 17:09:43
|
On Saturday 05 February 2005 08:21 am, Harald Harders wrote:
> A view days ago, Ethan has told me that it is possible to give the line
> color by specifying the rgb value. This is a great thing but I have not
> found out how to specify the line type (i.e., dash style), too.
> Do I miss something in the
> documentation or is that not possible yet?
It turns out that it is possible, although it was an unplanned feature.
Here is what I posted to the newsgroup yesterday:
In thinking about how this would have to work, I came to the unexpected
realization that it is already possible in the current CVS version of
gnuplot. This was not intentional; it's just a happy accident.
The key is that there is a recent feature that you can specify the color
of a line type, or line style, as an explicit RGB triple. Certain
well-known colors can be referenced by name. See "help colorspec".
The happy accident is that this is applied *on top of* whatever
characteristics the line already had. For most terminals that is
effectively just a replacement of one color by another. But for
a terminal that support dot/dash/solid line types, it is another story.
So what you can do right now with the CVS code is the following:
set term post color dash
set style line 1 lt rgb "red"
set style line 2 lt rgb "purple"
set style line 3 lt rgb "#FF00AA"
and so on. Each line style keeps its default dot/dash/solid pattern
from the default sequence, but you can assign any color you like to it.
Unfortunately you cannot currently set a line style to have a
different dot/dash pattern than it has by default, but for a totally
unintended feature that's not such a severe limitation.
Since the dot/dash pattern cycles every 9 style types, the following
demo give two sets of lines, one in red, the other in blue.
The red and blue sets contain matching solid and dashed types.
#
# Demonstrate forcing a fixed color onto dot/dash lines in postscript
#
set title "Forced combinations of color and dot/dash/solid\n(PostScript
terminals only)"
#
set term post eps color dash dl 3.0
set output 'dash.eps'
#
set style line 1 lt rgb 'red' lw 2
set style line 2 lt rgb 'red'
set style line 4 lt rgb 'red'
set style line 5 lt rgb 'red' lw 3
#
set style line 10 lt rgb 'blue' lw 2
set style line 11 lt rgb 'blue'
set style line 13 lt rgb 'blue'
set style line 14 lt rgb 'blue' lw 3
#
unset colorbox
set xrange [-1.8:1.8]
set yrange [0:1.1]
set key left
#
plot sin(x) ls 1 ti "ls 1", 0.8*sin(x) ls 2 ti "ls 2", \
0.6*sin(x) ls 4 ti "ls 4", 0.4*sin(x) ls 5 ti "ls 5", \
cos(x) ls 10 ti "ls 10", 0.8*cos(x) ls 11 ti "ls 11", \
0.6*cos(x) ls 13 ti "ls 13", 0.4*cos(x) ls 14 ti "ls 14"
> Another thing:
> Why does gnuplot switch on the color palette when using an rgb-defined
> color?
That's a bug, obviously. The problem is that the program is currently
only tracking the use of pm3d colors as TRUE or FALSE. It doesn't
separately track *why* they are being used. A similar problem exists
for surfaces. "splot sin(x) with lines lt rgb 'gold'" doesn't work,
because the flag for palette coloring causes it to color the whole
surface by Z value rather than recognizing that a single, uniform
color was requested.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington 98195-7742
|