Psxy -N does not allow -W lines to go outside box

Hi,
I was expecting that -N should let me draw outside the box with psxy, but that does not seem to happen?
reg=-R-1/1/-1/1
proj=-JX5
ofile=tmp.ps
psbasemap $reg $proj -P -Ba.5f.05 -K > $ofile
cat <<EOF | psxy -m $reg $proj -O -N -W >>$ofile

-W2,red
0 0
0 1
-W2,blue
0 0
1.05 0
EOF

looks like so


but I’d like the blue line to go outside the frame.

Bug or feature?

Thanks for the help.

GMT6 from recent git

1 Like

Yes, curious. We can plot points but not lines

julia> plot([0 0; 1.5 0], R="-1/1/-1/1", N=true, marker=:circ, lt=1, show=1)

From the documentation I get, that -N is only applied to symbols, but not to lines or polygons and they are always clipped, please see for classic mode psxy — GMT 6.5.0 documentation (generic-mapping-tools.org) or for modern mode plot — GMT 6.5.0 documentation (generic-mapping-tools.org).

Possible workaround: Size your plot large enough that your extension beyond the frame is plotted but without any frames. Overlay a basemap with all the frames and embellishments you want that is shorter in x direction. Now your line should extend beyond the frame.

This goes backs decades and how GMT deals with clipping polygons against map boundaries, which is not a trivial thing given periodicities in longitude etc. So since the Bush 1 administration the -N only applies to symbols which sets a clip path so that half-clipped symbols can bee seen at borders. Lines undergo a separate ritual where we compute intersections with boundaries and split lines into many segments or in the case of polygons add the missing segments along the border.

Yet, I also from time to time want to draw a polygon beyond the map border and it is painful to compute the required larger -R and scale and offsets to make it work. So I am working on a PR where -N will be acceptable with lines and polygons (not other lines like quoted lines and fronts which are hybrid things). It is assumed that the line is not wrapping around the Earth etc since there is no longer any checking: We simply convert the coordinates to plot coordinates and draw the line or polygon. So far it seems OK but I had to fix a few tests that incorrectly had a -N option in psxy calls for lines (which of course did nothing but now with my changes they do the wrong thing…).

For anyone interested in testing this PR that implements the ability to turn off clipping for lines and polygons, please go ahead.

1 Like

Thanks, I thought it was enabled for -W polygons as well in earlier versions, but must have dreamt that.

Thanks!

Thanks so much, Paul, for the explanation and quick work to get this going! Like mentioned to @yvonnefroehlich, I thought this was working in GMT4, but must have made that up. Looks like your patch is great! Thanks again!

1 Like

Now merged into master.

Thanks, Paul - works for the bounds, but now seems to have lost capability to pick up -W type instructions in the > headers?
reg=-R-1/1/-1/1
proj=-JX5
ofile=tmp.ps
psbasemap $reg $proj -P -Ba.5f.05 -K > $ofile
cat <<EOF | psxy -m $reg $proj -O -N >>$ofile

-W2,red
0 0
0 1
-W2,blue
0 0
1.1 0
EOF

Now fixed by this PR.

The best xmas present. Thanks, Paul!

Happy holidays and god jul to y’all

Likewise @thwbecker