Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing alias for option -F in basemap #1893

Closed
jackbeagley opened this issue Apr 22, 2022 · 5 comments · Fixed by #1894
Closed

Missing alias for option -F in basemap #1893

jackbeagley opened this issue Apr 22, 2022 · 5 comments · Fixed by #1894
Labels
feature request New feature wanted
Milestone

Comments

@jackbeagley
Copy link
Contributor

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
@jackbeagley jackbeagley added the bug Something isn't working label Apr 22, 2022
@welcome
Copy link

welcome bot commented Apr 22, 2022

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

@michaelgrund
Copy link
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")

@seisman seisman added feature request New feature wanted and removed bug Something isn't working labels Apr 22, 2022
@seisman seisman added this to the 0.7.0 milestone Apr 22, 2022
@jackbeagley
Copy link
Contributor Author

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(...)?

@seisman
Copy link
Member

seisman commented Apr 22, 2022

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")

@jackbeagley
Copy link
Contributor Author

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?

@seisman seisman changed the title Can't generate a filled in frame behind map_scale Missing alias for option -F in basemap Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants