When plotting lines over colorful background (i.e. elevation model) the line can be sometimes hard to see due to the color of the background and the pen used. It is not always possible to choose a pen color which has adequate contrast to the background.
Therefore I’m currently experimenting with ways to give the lines an outline. This is rather straightforward with solid lines but more difficult with dashed or dotted lines. I didn’t find an easy solution. Maybe you have some input for me on how to achieve this?
Here is what I got so far:
The goal here is to have a 4p wide line (white) with a 0.5p wide outline (black) making the whole thing 5p wide including said outline.
All lines run from bottom right to upper left.
All lines end “in” a dash to see the behavior when a dash is truncated.
How it was achieved:
Is just a solid white line on top of a solid black line. Minor ugliness are the open ends.
basically the same as 1 but used the build-in
-option for a dashed line. Results in different gait for white and black line. Not usable.
Made the dash pattern myself to have control over the length of dashes and gaps. The black dashes are as long as the white dashes. Way better than 2 but the open ends are somewhat ugly.
Black dashes are 1p (2 x outline width) longer, to compensate the black gaps are 1p smaller. The white dash and gap remains the same but with a 0.5p offset to allow for the outline at the beginning. Works nicely except for the end of line which is just cut off.
To get the black line to extend beyond the terminating coordinate I came up with the use of
--PS_LINE_CAP=squarefor the black line. The dash length and gap width needed adjustment to keep the dimensions the same. The offset of the white line needed some love as well. All that for a nicer look of the end. Found it to be uglier than 4.
basically the same as 4 but
--PS_LINE_CAP=roundwas used. Generally working fine but the black border bulges outwards at the dash ends. Except for the last cutoff dash. Not sure why.
Pretty much the same as 6 but with different offsets. I don’t fully understand why those multiples work. Looks good.
There is – in my understanding – no build-in way in GMT to get lines with outlines. My experimentation showed some usable ways (examples 4 and 7) but they are rather difficult as the offsets are dependent on line width, dash and gap length.
Is there an easier way to achieve this? Did I miss something in the docs? Your input is greatly appreciated.
All the best,
And I forgot to include the example code:
cat > path_1.txt << END 1.8 -0.7 0.2 1.2 -0.8 0.9 -1.8 1.3 END cat > path_2.txt << END 1.8 -0.9 0.2 1 -0.8 0.7 -1.8 1.1 END cat > path_3.txt << END 1.8 -1.1 0.2 0.8 -0.8 0.5 -1.8 0.9 END cat > path_4.txt << END 1.8 -1.3 0.2 0.6 -0.8 0.3 -1.8 0.7 END cat > path_5.txt << END 1.8 -1.5 0.2 0.4 -0.8 0.1 -1.8 0.5 END cat > path_6.txt << END 1.8 -1.7 0.2 0.2 -0.8 -0.1 -1.8 0.3 END cat > path_7.txt << END 1.8 -1.9 0.2 0 -0.8 -0.3 -1.8 0.1 END cat > noise.txt << END > -W60p,black -1.5 -1.5 -0.5 1.5 > -W60p,white -0.5 -1.5 0.5 1.5 > -W60p,red 0.5 -1.5 1.5 1.5 END cat > numbers.txt << END -1.9 0.1 7 -1.9 0.3 6 -1.9 0.5 5 -1.9 0.7 4 -1.9 0.9 3 -1.9 1.1 2 -1.9 1.3 1 # 1.9 -1.9 7 1.9 -1.7 6 1.9 -1.5 5 1.9 -1.3 4 1.9 -1.1 3 1.9 -0.9 2 1.9 -0.7 1 END gmt begin outlines gmt basemap -R-2/2/-2/2 -JM6i -Bafg1 --PS_PAGE_COLOR=lightgrey gmt plot noise.txt gmt text numbers.txt # solid gmt plot path_1.txt -W5p,black+s gmt plot path_1.txt -W4p,white+s # dash build in gmt plot path_2.txt -W5p,black,-+s gmt plot path_2.txt -W4p,white,-+s # dash home made gmt plot path_3.txt -W5p,black,32_16+s gmt plot path_3.txt -W4p,white,32_16+s # dash home made gmt plot path_4.txt -W5p,black,33_15+s gmt plot path_4.txt -W4p,white,32_16:-0.5+s # dash home made gmt plot path_5.txt -W5p,black,28_20:-2.5+s --PS_LINE_CAP=square gmt plot path_5.txt -W4p,white,32_16:-0.5+s # dash home made gmt plot path_6.txt -W5p,black,33_15+s --PS_LINE_CAP=round gmt plot path_6.txt -W4p,white,32_16:-0.5+s --PS_LINE_CAP=round # dash home made gmt plot path_7.txt -W5p,black,32.125_15.875+s --PS_LINE_CAP=round gmt plot path_7.txt -W4p,white,32_16:-0.0625+s --PS_LINE_CAP=round gmt end show