Skip to content

Plot labels do not allow spaces #1849

Description

@seismomomo

(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

Activity

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

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions