GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
758 stars 220 forks source link

fig.plot fails when labels contain spaces #402

Closed firstkingofrome closed 4 years ago

firstkingofrome commented 4 years ago

Hello, I am unable to use the figure.plot command if my label contains a space: For example the following works:

import pygmt as gmt fig = gmt.Figure() h1 = fig.plot(x=[-5], y=[5], region=[-10, 10, -5, 10], projection='X3i/0', frame='a', style='a25p', color="purple",label="H 1") h2 = fig.plot(x=[0], y=[5], style='t15p', color='cyan',label="H2") fig.legend(position="JBL+jBL+o0.2c",L="2p",box="+gseashell") fig.show()

However if I change a label to include a space, the plot instruction fails: GMTCLibError: Module 'plot' failed with status code 71: plot [ERROR]: Error for input file: No such file (1) `import pygmt as gmt fig = gmt.Figure()

h1 = fig.plot(x=[-5], y=[5], region=[-10, 10, -5, 10], projection='X3i/0', frame='a', style='a25p', color="purple",label="H 1") h2 = fig.plot(x=[0], y=[5], style='t15p', color='cyan',label="H2") fig.legend(position="JBL+jBL+o0.2c",L="2p",box="+gseashell") fig.show()`

Any idea how to fix this? Thank You I appreciate any assistance!

seisman commented 4 years ago

Same issue as #247. Please refer to #247 for workarounds.

weiji14 commented 4 years ago

Hi @firstkingofrome,

It's a known problem in #247. You'll need to do:

h1 = fig.plot(x=[-5], y=[5], region=[-10, 10, -5, 10], projection='X3i/0', frame='a', style='a25p', color="purple", label="'H 1'")

Note that is has to be single-quotes ' ' nested inside the double-quotes " ".

Feel free to close this if it solves your problem :smile:. Also just so you know, you're welcome to post more questions on our forum at https://forum.generic-mapping-tools.org/, just sign in with your Github account. Cheers.

firstkingofrome commented 4 years ago

Oh ok thank you ill do that! Also sorry I didn't see that other issue.