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

Plot labels do not allow spaces #1849

Closed
seismomomo opened this issue Mar 26, 2022 · 2 comments
Closed

Plot labels do not allow spaces #1849

seismomomo opened this issue Mar 26, 2022 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@seismomomo
Copy link

seismomomo commented Mar 26, 2022

(Sorry for multiple edits) The label string does not allow for two words to be separated by a space.

Full code that generated the error

fig.plot(x=df_mis.lon, y=df_mis.lat, 
         pen=f'0.5p,{c_pen}', style='s0.15', color=c_mis, transparency=50, 
         label='Mining events')

Full error message

plot [ERROR]: Cannot find file events
---------------------------------------------------------------------------
GMTCLibError                              Traceback (most recent call last)
Input In [279], in <module>
     22 fig.plot(x=df_eq.lon, y=df_eq.lat, 
     23          pen=f'0.5p,{c_pen}', style='c0.1', color=c_eq, transparency=50, 
     24          label='Earthquake')
     25 fig.plot(x=df_ex.lon, y=df_ex.lat, 
     26          pen=f'1p,{c_ex}', style='x0.15', transparency=40, 
     27          label='Explosion')
---> 28 fig.plot(x=df_mis.lon, y=df_mis.lat, 
     29          pen=f'0.5p,{c_pen}', style='s0.15', color=c_mis, transparency=50, 
     30          label='Mining events')
     31 fig.legend()
     33 # right plot

File [path to env]/lib/python3.10/site-packages/pygmt/helpers/decorators.py:805, in deprecate_parameter.<locals>.deprecator.<locals>.new_module(*args, **kwargs)
    803     warnings.warn(msg, category=FutureWarning, stacklevel=2)
    804     kwargs[newname] = kwargs.pop(oldname)
--> 805 return module_func(*args, **kwargs)

File [path to env]/lib/python3.10/site-packages/pygmt/helpers/decorators.py:805, in deprecate_parameter.<locals>.deprecator.<locals>.new_module(*args, **kwargs)
    803     warnings.warn(msg, category=FutureWarning, stacklevel=2)
    804     kwargs[newname] = kwargs.pop(oldname)
--> 805 return module_func(*args, **kwargs)

File [path to env]/lib/python3.10/site-packages/pygmt/helpers/decorators.py:873, in check_data_input_order.<locals>.data_input_order_checker.<locals>.new_module(*args, **kwargs)
    865     msg = (
    866         "The function parameters has been re-ordered as 'data, x, y, [z]' "
    867         f"since {deprecate_version} but you're passing positional arguments. "
   (...)
    870         f"in {remove_version}."
    871     )
    872     warnings.warn(msg, category=FutureWarning, stacklevel=2)
--> 873 return module_func(*args, **kwargs)

File [path to env]/lib/python3.10/site-packages/pygmt/helpers/decorators.py:586, in use_alias.<locals>.alias_decorator.<locals>.new_module(*args, **kwargs)
    581         msg = (
    582             f"Short-form parameter ({short_param}) is not recommended. "
    583             f"Use long-form parameter '{long_alias}' instead."
    584         )
    585         warnings.warn(msg, category=SyntaxWarning, stacklevel=2)
--> 586 return module_func(*args, **kwargs)

File [path to env]/lib/python3.10/site-packages/pygmt/helpers/decorators.py:726, in kwargs_to_strings.<locals>.converter.<locals>.new_module(*args, **kwargs)
    724             kwargs[arg] = separators[fmt].join(f"{item}" for item in value)
    725 # Execute the original function and return its output
--> 726 return module_func(*args, **kwargs)

File [path to env]/lib/python3.10/site-packages/pygmt/src/plot.py:275, in plot(self, data, x, y, size, direction, **kwargs)
    273 with file_context as fname:
    274     arg_str = " ".join([fname, build_arg_string(kwargs)])
--> 275     lib.call_module("plot", arg_str)

File [path to env]/lib/python3.10/site-packages/pygmt/clib/session.py:500, in Session.call_module(self, module, args)
    496 status = c_call_module(
    497     self.session_pointer, module.encode(), mode, args.encode()
    498 )
    499 if status != 0:
--> 500     raise GMTCLibError(
    501         f"Module '{module}' failed with status code {status}:\n{self._error_message}"
    502     )

GMTCLibError: Module 'plot' failed with status code 72:
plot [ERROR]: Cannot find file events

System information

PyGMT information:
  version: v0.5.0
System information:
  python: 3.10.2 | packaged by conda-forge | (main, Jan 14 2022, 08:02:19) [GCC 9.4.0]
  executable: [path to env]/bin/python
  machine: Linux-3.10.0-1160.36.2.el7.x86_64-x86_64-with-glibc2.17
Dependency information:
  numpy: 1.21.5
  pandas: 1.3.5
  xarray: 0.19.0
  netCDF4: 1.5.8
  packaging: 21.3
  ghostscript: 9.54.0
  gmt: 6.3.0
GMT library information:
  binary dir:[path to env]/bin
  cores: 64
  grid layout: rows
  library path: [path to env]/lib/libgmt.so
  padding: 2
  plugin dir: [path to env]/lib/gmt/plugins
  share dir: [path to env]/share/gmt
  version: 6.3.0
@seismomomo seismomomo added the bug Something isn't working label Mar 26, 2022
@welcome
Copy link

welcome bot commented Mar 26, 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.

@seismomomo seismomomo changed the title Plot label cannot include the term "mining" Plot label cannot include the terms "mining" and "events" together Mar 26, 2022
@seismomomo seismomomo changed the title Plot label cannot include the terms "mining" and "events" together Plot labels do not allow spaces Mar 26, 2022
@weiji14
Copy link
Member

weiji14 commented Mar 26, 2022

Hi @seismomomo, this space issue has been fixed in #1487 and is available in the latest version of PyGMT (v0.6.0), so you can upgrade to get the fix.

Alternatively if you want to stay on PyGMT v0.5.0, use label='"Some label"' (double quotes inside single quotes). See #247 or #1632 for a longer explanation.

@seisman seisman closed this as completed Mar 27, 2022
@weiji14 weiji14 added the duplicate This issue or pull request already exists label Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants