Is the following command valid in PyGMT?
fig.basemap(frame=[True, "+tThe Caribbean Sea"])
I’m wondering if it’s allowed to use a list with mixed data types (in this case, a boolean and a string), or if all elements in the list should be of the same type.
I tried the command above, but it gave me an error.
However, this version worked fine:
fig.basemap(frame=["afg", "+tThe Caribbean Sea"])
Is this expected behavior? Should I avoid mixing data types in the list for the frame
parameter?
Thanks!
I managed to make it worked with this:
fig.basemap(frame=True)
fig.basemap(frame="+tThe Caribbean Sea")
But I still wants to know the answer to my question.
This worked in my script. So I can combine a int
and a string
.
fig.basemap(frame=['0', "+tThe Caribbean Sea"])
Hi @Esteban82,
nice to see that your are trying PyGMT
!
-B or frame
is probably one of the most complicated flages or parameters. And due to the complexity in GMT it’s probably not so straight forwardt to wrap it in PyGMT.
frame=True
in PyGMT is equivalent to -B in GMT. frame=False
(and frame=None
; see also Setting frame=None gives unexpected results · Issue #1665 · GenericMappingTools/pygmt · GitHub) is actually not working, but one can use frame="+gwhite"
(or play around for the GMT defaults for the pen used for the frame) to get ride of the frame.
For the frame
parameter, it’s possible to combine string
and integer
or float
within a list, but not bool
.
import pygmt
size = 5
fig = pygmt.Figure()
fig.basemap(
region=[-size, size] * 2,
projection=f"X{size *2}",
frame=[2, "WSNE+tTitel+gcyan"],
)
fig.show()
Personally, I think it makes sense to use the data type that represents the input best.
Edit: And over time there will be probably changes due to the implementation of a new alias system, please see issue New alias system towards a more Pythonic interface · Issue #3239 · GenericMappingTools/pygmt · GitHub.
Thanks Yvonne.
Some more questions. This is something that is not possible to do only with frame
? or with any pygmt parameter? is it expected that in the future will be possible to combine bool in a list?
Could you please open a bug report in the pygmt repository? I think it’s an unexpected bug, but I haven’t checked carefully if there is an easy fix.