Feature #1200

Plotting double-headed vectors with centre of vector at supplied coordinates (GMT5)

Added by Andy 28 days ago. Updated 8 days ago.

Status:ClosedStart date:2018-02-19
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next bugfix release


My apologies if this is something that is already possible, but I have just missed. I also apologise for not being able to supply any code for this—my C is non-existent.

I would like to be able to plot vectors with arrowheads at both ends, such that the middle of the vector lies at the point I specify.

This used to be possible with the `-SvB` or `-SVB` options in GMT4, but I can't find any way to do this in GMT5 without changing my input. I know I can simply draw two vectors of half the original length at angle and angle+180°, but this doesn't have the desired effect when one wants an outline to be drawn for the whole vector—one would get a line in the middle of the vector where the ends meet. (As it happens, I haven't been able to draw only outlines so far in any case.)

As an example:


data="0 0 12 6c" 

# Desired behaviour with GMT4
echo "$data" |
    psxy -JQ0/10c -R-1/1/-1/1 -B:."Desired behaviour":nsew -W0.5p -SVB0.15c/0.2c/0.15c > fig_desired.ps

# Attempt at desired behaviour with GMT5, without trigonometry to get head length of desired size
rm fig.ps
echo "$data" |
    awk '{
        x = $1
        y = $2
        a = $3
        lenstr = $4
        len = substr(lenstr, 1, length(lenstr)-1)/2
        unit = substr(lenstr, length(lenstr))
        print x, y, a, len unit
        print x, y, (a+180)%360, len unit
    }' |
    gmt psxy -JQ0/10c -R-1/1/-1/1 -Bxya -Bnsew+t"GMT5 attempt" -W0.15c \
        -SV0.2c+a63+e+g-+p0.5p,black -P > fig.ps

Here, I also can't see why the vector is filled (having used `-g-`).

If it would be possible to add back the functionality of plotting the midpoint of a vector at the given coordinates, I would be very grateful.

fig_desired.ps - Desired output (16.1 KB) Andy, 2018-02-19 06:48

fig.ps - Best GMT 5 attempt (20.7 KB) Andy, 2018-02-19 06:48


#1 Updated by Paul 28 days ago

  • Status changed from New to Feedback

Per the documentation you need +jc to center the vector at the data point, and +b+e to draw heads at either end.

#2 Updated by Andy 28 days ago

Apologies for the trouble and thanks very much for pointing out what I missed. Would you recommend opening a separate issue about my inability to draw the outline of the vector only?

#3 Updated by Paul 27 days ago

Sure, if you want to retain the old-style GMT4 outline only polygon vectors then you need to do the old-style -SVB syntax with arguments as per GMT4 documentation and GMT5/6 should honor that. If not, please post a short example that can reproduce any problem you run into and we will have a look. GMT5 introduced geo-vectors and a full redesign of vectors where the vector stem is a line and the vector head is a polygon; In GMT4 it was a single polygon only, so we cannot mix and match on the syntax.

#4 Updated by Andy 27 days ago

Thanks for the explanation and suggestion. Using -SVB works fine for my purposes, though of course one gets a deprecation warning and this use is therefore undocumented. I guess from what you're saying that this won't be removed in GMT5 or 6, but presumably after that it's fair game to be taken out.

#5 Updated by Paul 25 days ago

  • Status changed from Feedback to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next bugfix release
  • % Done changed from 0 to 100

Since we will leave the GMT4 vector in GMT5 and later versions I have removed the deprecated message and added a syntax reference as a note to the psxy documentation.

#6 Updated by Paul 8 days ago

  • Status changed from Resolved to Closed

Closed as fixed.

Also available in: Atom PDF