You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Figure.text: Parsing of additional arguments when plotting text from file #479
I am finding that adding text from a file isn't working as expected (based on the GMT documentation). The additional arguments are not parsed, instead the input files are treated as if there were only 3 input columns (x, y, text).
Full code that generated the error
You will need an additional file: echo 117,5.2,Helvetica,0,CM,SABAH > example.txt
This actually appeared to be a problem with GMT 6 as well. Maybe I'm just missing something? I am interpreting it from: This is one or more files containing 1 or more records with (x, y[, font, angle, justify], text). If so, apologies. I also tried delimiting with spaces instead of commas to no avail.
System information
Please paste the output of python -c "import pygmt; print(pygmt.__version__)":
v0.1.1
(Note: I had to change the above command, as pygmt.show_versions() didn't exist!)
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.
This is one or more files containing 1 or more records with (x, y[, font, angle, justify], text). The attributes in brackets can alternatively be set directly via -F.
The font, angle and justify are not needed unless you add more modifiers to -F option.
For example, if you don't use -F option, then your input data should be: x y text, e.g.,
echo 117 5.2 SABAH | gmt text -R108/120/-5/8 -JM20c -Ba -pdf map
If you use -F+f+a+j, then your input file format is: x y font angle justify text, e.g.,
echo 117 5.2 Helvetica 0 CM SABAH | gmt text -R108/120/-5/8 -JM20c -Ba -F+f+a+j -pdf map
Ok - I understand now, though I do not think it is made adequately clear in the documentation that you must add this -F+f+a+j in order for it to work.
The attributes in the brackets can alternatively be set directly via -F.
This phrasing suggests you can use fields in the text file OR set them with -F.
I see why there would be issues replicating this with the current implementation of the PyGMT text binding. I'm happy for this issue to be closed and I'll gather my thoughts and open a new issue (as suggested by you here) on the implementation of text in PyGMT. Thanks for your response.
Unfortunately, the current PyGMT text implementation hardcodes the +a+f+j order, so passing in either fig.text(..., angle=True, font=True, justify=True) or fig.text(..., font=True, angle=True, justify=True) doesn't make a difference, fig.text will still expect columns in +a+f+j order, which is tricky if your data columns were designed for GMT and you want to port them to PyGMT. Note that this only applies when using the textfiles argument, doing fig.text(x=1, y=2, text="lala", ...) will still be fine.
Unfortunately, the current PyGMT text implementation hardcodes the +a+f+j order, so passing in either fig.text(..., angle=True, font=True, justify=True) or fig.text(..., font=True, angle=True, justify=True) doesn't make a difference, fig.text will still expect columns in +a+f+j order
I think we don't have many choices. The only two options I can see:
Improve the docstrings to make it clear that the order of the three columns must be angle font justify.
Add one more parameter like justify_first. If it's true, then angle justify font.
I prefer to option 1 because with option 2, (1) the codes will be more complicated; (2) angle is still required to be the 3rd column, so it's impossible to be as flexible as the GMT CLI.
changed the title [-]Parsing of additional arguments when plotting text from file[/-][+]Figure.text: Parsing of additional arguments when plotting text from file[/+]on Oct 9, 2023
Activity
welcome commentedon Jun 17, 2020
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.
seisman commentedon Jun 17, 2020
The text documentation says:
The font, angle and justify are not needed unless you add more modifiers to -F option.
For example, if you don't use -F option, then your input data should be:
x y text, e.g.,If you use -F+f+a+j, then your input file format is:
x y font angle justify text, e.g.,hemmelig commentedon Jun 18, 2020
Ok - I understand now, though I do not think it is made adequately clear in the documentation that you must add this -F+f+a+j in order for it to work.
This phrasing suggests you can use fields in the text file OR set them with -F.
I see why there would be issues replicating this with the current implementation of the PyGMT text binding. I'm happy for this issue to be closed and I'll gather my thoughts and open a new issue (as suggested by you here) on the implementation of text in PyGMT. Thanks for your response.
weiji14 commentedon Jun 18, 2020
Oops, this is only available on the
masterpygmt branch. Will need to do a properpygmtrelease to get it to work!weiji14 commentedon Jun 21, 2020
Just to cross-reference #481 (comment) and confuse things further, it should be
-F+a+f+jinstead of-F+f+a+j, because GMT requires external interfaces (like PyGMT) to have numerical columns (like angle) first, and the text columns (like font, justify) later. See also https://docs.generic-mapping-tools.org/dev/text.html#use-from-external-interface.Unfortunately, the current PyGMT
textimplementation hardcodes the+a+f+jorder, so passing in eitherfig.text(..., angle=True, font=True, justify=True)orfig.text(..., font=True, angle=True, justify=True)doesn't make a difference,fig.textwill still expect columns in+a+f+jorder, which is tricky if your data columns were designed for GMT and you want to port them to PyGMT. Note that this only applies when using thetextfilesargument, doingfig.text(x=1, y=2, text="lala", ...)will still be fine.seisman commentedon Oct 7, 2023
I think we don't have many choices. The only two options I can see:
angle font justify.justify_first. If it's true, thenangle justify font.I prefer to option 1 because with option 2, (1) the codes will be more complicated; (2) angle is still required to be the 3rd column, so it's impossible to be as flexible as the GMT CLI.
[-]Parsing of additional arguments when plotting text from file[/-][+]Figure.text: Parsing of additional arguments when plotting text from file[/+]