Skip to content

gmt text -Dj argument not functioning as intended #5981

@NevPalmer

Description

@NevPalmer

Description of the problem

When using the command gmt text -M for plotting files of multi-line text, the -Dj option does not correctly offset the text with respect to the specified justification (TL, BR, etc).
This issue only occurs with multi-line text. Standard single-line text plots offset correctly as expected.

Full script that generated the error

#! /usr/bin/env bash
gmt begin test_plot pdf

    gmt basemap -R10/70/-3/8 -JX15c/10c -B -B+glightgreen+t"Test plot"

# The following displays as expected with no -Dj parameter specified
    gmt text -M -F+f+a+j <<EOF
>30 3 10p,Times-Bold,black 0 TR 0.32c 2c r
Original  X
Multiline.
EOF
# The following does not displays as expected
# with the -Dj parameter specified the multiline text is always offset with
# respect to +x +y and not in the direction relevant to the justification
# (In this case because TR is used I would expect the offset to be -x -y)
    gmt text -M -F+f+a+j -Dj2c <<EOF
>30 3 10p,Times-Bold,black 0 TR 0.32c 2c r
Offset   X
Multiline.
EOF

# When standerd single line text is plotted the -Dj offset is applied as expected
# with respect to the specified justification (TR in the 2nd example).
    gmt text -F+f+a+j <<EOF
50 3 10p,Helvetica,red 0 TR Original single line. X
EOF
    gmt text -F+f+a+j -Dj2c <<EOF
50 3 10p,Helvetica,red 0 TR Offset single line. X
EOF

gmt end

Full error message

There is no error message. The plotted text is offset incorrectly.

Actual outcome
The single-line and multi-line text are both specified to offset similarly but they offset in opposite directions as ahown in this PDF, which was generated from the above script.
test_plot.pdf

Expected outcome

The offset direction when specified by -Dj should be as defined by the text justification.
eg text justified TR should offset -x -y
or text justified BL should offset +x +y

System information

  • Operating system:
  • GMT version (gmt --version): 6.1.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions