Repository navigation
Closed
Labels
Milestone
Description
Description of the problem
Full code that generated the error
I tried to plot a basemap with an axis labelled as "Crust Age". I tried in three different ways:
import gmt
fig = gmt.Figure()
# 1st way: FAIL
fig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B='x20+lCrust Age')
# 2nd way: SUCCEED
fig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B='x20+l"Crust Age"')
# 3rd way: FAIL
fig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B="x20+l'Crust Age'")
fig.savefig("map.pdf")Full error message
psbasemap [ERROR]: Unrecognized option -<
Traceback (most recent call last):
File "test.sh", line 6, in <module>
fig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B="x20+l'Crust Age'")
File "/Users/seisman/Gits/gmt/gmt-python/gmt/helpers/decorators.py", line 199, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/gmt-python/gmt/helpers/decorators.py", line 294, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/gmt-python/gmt/base_plotting.py", line 472, in basemap
lib.call_module("basemap", build_arg_string(kwargs))
File "/Users/seisman/Gits/gmt/gmt-python/gmt/clib/session.py", line 490, in call_module
module, status, self._error_message
gmt.exceptions.GMTCLibError: Module 'basemap' failed with status code 71:
psbasemap [ERROR]: Unrecognized option -<
The 1st way is equivalent to command line
gmt basemap -R0/100/0/50 -JX10c/5c -Bx20+lCrust Age
The command fails because "Age" is thought to be a file. However, the error message is almost useless to help users find the error. Do you think it's technically possible to automatically add quotes around strings with spaces if users forget to do that?
The 2nd way works as expected. However, I don't understand why the 3rd way fails? The equivalent cmd version works:
gmt basemap -R0/100/0/50 -JX10c/5c -Bx20+l'Crust Age' -pdf map
System information
- Operating system: macOS
- Python installation (Anaconda, system, ETS): Anaconda
- Version of GMT: 6.0.0_15a9160
- Version of Python: 3.7.0
- Version of this package: latest
Activity
leouieda commentedon Nov 28, 2018
This is something we'll have to work on. I really don't like the way that -B works right now. It's very non-intuitive and requires the user to specify it multiple times. There shouldn't be a single argument for setting labels, titles, gridlines, tickmarks, etc. See #249. I think that's a better solution than trying to guess what the user is doing with their ticks.
Allow for spaces in title and labels without needing double quotes
Wrap subplot using with statement (#822)
seisman commentedon Mar 25, 2021
NOTE: the
list2cmdlinefunction may be helpful.weiji14 commentedon Sep 6, 2021
Just had an idea from #1474 (comment), how about we find and replace space characters (
) to use the octal code for space (\040)? Reference from https://docs.generic-mapping-tools.org/6.2/cookbook/octal-codes.html. Proof of concept below using PyGMT v0.4.1:Caveat is that we will need to use raw-strings
r'Some\040string', but I think this is definitely a good way to go.Wrap subplot using with statement (GenericMappingTools#822)