查看完整版本 : white line?


ionization
2006-04-08 06:33
How can I plot a line with the color white in gnuplot? Thanks!


xhsh
2006-05-12 09:12
引用:(ionization @ 2006-04-08 06:33)
How can I plot a line with the color white in gnuplot? Thanks!




In X11 terminal, we can not plot with white lines. However, you can save the color figure in an eps file and then modify the color of the specified curve. Now I will introduce how to do it.





Here is a tricky way to change the colors. Edit the postscript file by hand. The PS file generated by gnuplot is rather easy to read. With the following gnuplot commands you can get a color index. Of course the test command yields the color index, too.



gnuplot> set term postscript enhanced color

gnuplot> set output "colorindex.ps"

gnuplot> set size 0.5,0.5

gnuplot> set noborder

gnuplot> set nokey

gnuplot> set linestyle 1 linetype 1 linewidth 8

gnuplot> set linestyle 2 linetype 2 linewidth 8

gnuplot> set linestyle 3 linetype 3 linewidth 8

gnuplot> set linestyle 4 linetype 4 linewidth 8

gnuplot> set linestyle 5 linetype 5 linewidth 8

gnuplot> set linestyle 6 linetype 6 linewidth 8

gnuplot> set linestyle 7 linetype 7 linewidth 8

gnuplot> set linestyle 8 linetype 8 linewidth 8

gnuplot> set linestyle 9 linetype 9 linewidth 8

gnuplot> set linestyle 10 linetype 10 linewidth 8

gnuplot> # for gnuplot ver.4

gnuplot> # set style line 1 line type 1 linewidth 8

gnuplot> # ... etc

gnuplot> set noxtics

gnuplot> set ytics nomirror 1

gnuplot> set yrange [ -1.5 : 10.5 ]

gnuplot> plot 1 w l ls 1, 2 w l ls 2, 3 w l ls 3, 4 w l ls 4,\

gnuplot> 5 w l ls 5, 6 w l ls 6, 7 w l ls 7, 8 w l ls 8,\

gnuplot> 9 w l ls 9, 10 w l ls 10, -1 w line -1, 0 with line 0

gnuplot> pause -1



Ten line types are defined in the Postscript terminal, those are numbered from 1 to 9. Above, functions y=1 to y=10 are displayed with the various line types. In order to see the color clearly very thick lines are used there.



Do the same thing but with a B/W Postscript. Remove the color option, and save the output into "monoindex.ps". You can see the difference between "colorindex.ps" and "monoindex.ps" with the diff command on UNIX. The difference is only one line, /Color true def and /Color false def . Therefore you can choose color or B/W without gnuplot by editing this part /Color {true |false}.



Lets read the PS file generated above, you can easily find the place where colors are defined. Near line 40th, you see the following section (extra spaces are inserted here to align).



/LT0 {PL [ ] 1 0 0 DL} def

/LT1 {PL [4 dl 2 dl ] 0 1 0 DL} def

/LT2 {PL [2 dl 3 dl ] 0 0 1 DL} def

/LT3 {PL [1 dl 1.5 dl ] 1 0 1 DL} def

/LT4 {PL [5 dl 2 dl 1 dl 2 dl ] 0 1 1 DL} def

/LT5 {PL [4 dl 3 dl 1 dl 3 dl ] 1 1 0 DL} def

/LT6 {PL [2 dl 2 dl 2 dl 4 dl ] 0 0 0 DL} def

/LT7 {PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl ] 1 0.3 0 DL} def

/LT8 {PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL} def



Those lines correspond to the line types 1 to 9. Three numbers in LT0, "1 0 0" defines RGB (Red, Green, and Blue), then LT0 becomes red. In the same manner, LT1 is green, LT2 is blue...and (1,0,1)=Magenta, (0,1,1)=Cyan, (1,1,0)=Yellow, (0,0,0)=Black, (1,0.3,0)=Orange, and (0.5,0.5,0.5)=Gray. Now you can change the line color by changing these RGB values.



To make a gradation from red to yellow, fix the R=1 and Blue=0, and change G from 0 to 1 gradually.



/LT0 {PL [ ] 1 0 0 DL} def

/LT1 {PL [4 dl 2 dl ] 1 0.1 0 DL} def

/LT2 {PL [2 dl 3 dl ] 1 0.2 0 DL} def

/LT3 {PL [1 dl 1.5 dl ] 1 0.3 0 DL} def

/LT4 {PL [5 dl 2 dl 1 dl 2 dl ] 1 0.4 0 DL} def

/LT5 {PL [4 dl 3 dl 1 dl 3 dl ] 1 0.5 0 DL} def

/LT6 {PL [2 dl 2 dl 2 dl 4 dl ] 1 0.6 0 DL} def

/LT7 {PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl ] 1 0.7 0 DL} def

/LT8 {PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.8 0 DL} def



The results are as follows. The first image is generated with gnuplot, while the second one is made with editing the PS file as described above. With this method you can use any colors in you figure. An automatic conversion of those colors can be achieved with some programs like perl or sed.



Therefore, if you want to see a white line, you can change the RGB value of the linetype of your curve to 1 1 1. That will work!



Good luck!!



sample8.4a.png - 文件大小3.9KB (点击缩略图放大查看) sample8.4b.png - 文件大小3.9KB (点击缩略图放大查看)