Skip to content

Missing alias for option -F in basemap #1893

Closed

Description

@jackbeagley

Description of the problem

I am trying to add a filled background behind my mapscale, similar to the examples in the GMT documentation here: https://docs.generic-mapping-tools.org/dev/cookbook/features.html#placing-map-scales. From what I understand, when adding the map_scale, I should be able to simultaneously add a frame option specifying the fill parameters, like in my example code below, using the options from the GMT documentation. The code below runs when 'frame' isn't specified, but of course no background is generated behind the map_scale. I would be very appreciative if someone could point me in the right direction or let me know if this is in fact a bug. Thanks!

Full code that generated the error

import pygmt

fig = pygmt.Figure()
fig.coast(
    # Set the x-range from 10E to 20E and the y-range to 35N to 45N
    region=[10, 20, 35, 45],
    projection="M12c",
    land="lightgray",
    water="white",
    borders="1/0.5p",
    shorelines="1/0.5p",
    frame="ag",
)
fig.basemap(map_scale='jBR+c36N+w100k+l+f', frame='+p1p+i+gwhite+c0.1i')
fig.show()

Full error message

pygmt.exceptions.GMTCLibError: Module 'basemap' failed with status code 72:
basemap [ERROR]: Option -B: Found frame setting modifiers (+b|g|i|n|o|t|w|x|y|z) mixed with axes settings!
basemap [ERROR]: Option -B parsing failure. Correct syntax:
basemap [ERROR]: Offending option -B+p1p+i+gwhite+c0.1i

System information

Please paste the output of python -c "import pygmt; pygmt.show_versions()":

PyGMT information:
  version: v0.6.1
System information:
  python: 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:24:38)  [Clang 12.0.1 ]
  executable: /opt/homebrew/Caskroom/miniforge/base/bin/python
  machine: macOS-12.3.1-arm64-arm-64bit
Dependency information:
  numpy: 1.22.3
  pandas: 1.4.2
  xarray: 2022.3.0
  netCDF4: 1.5.7
  packaging: 21.3
  geopandas: 0.10.2
  ghostscript: 9.56.1
  gmt: 6.3.0
GMT library information:
  binary dir: /opt/homebrew/Caskroom/miniforge/base/bin
  cores: 10
  grid layout: rows
  library path: /opt/homebrew/Cellar/gmt/6.3.0_2/lib/libgmt.dylib
  padding: 2
  plugin dir: /opt/homebrew/Cellar/gmt/6.3.0_2/lib/gmt/plugins
  share dir: /opt/homebrew/Cellar/gmt/6.3.0_2/share/gmt
  version: 6.3.0

Activity

  1. added
    bug
    on Apr 22, 2022
  2. welcome commented on Apr 22, 2022

    @welcome

    👋 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.

  3. michaelgrund commented on Apr 22, 2022

    @michaelgrund
    Member

    The background color of the scale can be defined via the -F flag for which no alias is available so far in PyGMT. So, the following will do the job:

    fig.basemap(map_scale = "jBR+c36N+w100k+l+f", F = "+glightcyan+c0+p")
    

  4. added
    feature request
    and removed
    bug
    on Apr 22, 2022
  5. added this to the 0.7.0 milestone on Apr 22, 2022
  6. jackbeagley commented on Apr 22, 2022

    @jackbeagley
    ContributorAuthor

    Far out that was easy... thanks @michaelgrund! @seisman what would this look like as a feature request? Could we have a method specifically for making map_scales? something like fig.map_scale(...)?

  7. seisman commented on Apr 22, 2022

    @seisman
    Member

    what would this look like as a feature request? Could we have a method specifically for making map_scales? something like fig.map_scale(...)?

    We just need to add an alias F="box" to the @use_alias decorator in the basemap function:

    @use_alias(
    R="region",
    J="projection",
    Jz="zscale",
    JZ="zsize",
    B="frame",
    L="map_scale",
    Td="rose",
    Tm="compass",
    U="timestamp",
    V="verbose",
    X="xshift",
    Y="yshift",
    c="panel",
    f="coltypes",
    p="perspective",
    t="transparency",
    )

    then you can use:

    fig.basemap(map_scale = "jBR+c36N+w100k+l+f", box="+glightcyan+c0+p")
    
  8. jackbeagley commented on Apr 22, 2022

    @jackbeagley
    ContributorAuthor

    what would this look like as a feature request? Could we have a method specifically for making map_scales? something like fig.map_scale(...)?

    We just need to add an alias F="box" to the @use_alias decorator in the basemap function:

    @use_alias(
    R="region",
    J="projection",
    Jz="zscale",
    JZ="zsize",
    B="frame",
    L="map_scale",
    Td="rose",
    Tm="compass",
    U="timestamp",
    V="verbose",
    X="xshift",
    Y="yshift",
    c="panel",
    f="coltypes",
    p="perspective",
    t="transparency",
    )

    then you can use:

    fig.basemap(map_scale = "jBR+c36N+w100k+l+f", box="+glightcyan+c0+p")
    

    This seems very straightforward... are you happy if I have a crack at it?

  9. changed the title [-]Can't generate a filled in frame behind map_scale[/-] [+]Missing alias for option -F in basemap[/+] on Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions