Access current PyGMT parameters

I’m familiar with using clib.Session.extract_region() to access the most recent region used in PyGMT and was hoping there would be equivalent methods to access other values. Mostly I was hoping to get the min and max values of the current cmap and the current projection string. Any idea on how to access these variables? Thanks :slight_smile:

Currently, we could add a function to return the current values of the following common options:

  • spacing
  • xshift
  • yshift
  • coltypes
  • incols
  • outcols
  • registration
  • transparency

any other values would require an upstream feature request to the GMT C API.

Okay thanks for that. Would we also need an upstream request to get the figure width and height?

Is the « mapproject » module implemented in pygmt? If it is, then you can get it with -Wh and -Ww

It’s not yet wrapped, this is being tracked in

Stdout of modules (e.g. mapproject) using pygmt.clib.Session.call_module has a workaround to get this information. Note that this is the map width/height though, not the figure weight/height (e.g., including multiple subplots).

Thanks for that link to that mapproject workaround! I’ll definitely use that in the meantime.

Is there an equivalent workaround for getting the current projection string?

Not that I know of

If I remember well PyGMT has also a mechanism to print the generated GMT string (a higher level of -V?). Parsing that (or those) sting(s) should be enough to extract the projection.