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

Figure.text sometimes doesn't work if the text contains single/double quotation marks #3104

Closed
xumi1993 opened this issue Mar 13, 2024 · 3 comments · Fixed by #3179 · May be fixed by #3105
Closed

Figure.text sometimes doesn't work if the text contains single/double quotation marks #3104

xumi1993 opened this issue Mar 13, 2024 · 3 comments · Fixed by #3179 · May be fixed by #3105
Labels
bug Something isn't working
Milestone

Comments

@xumi1993
Copy link

Description of the problem

I want to write text of A' on a figure with text box filled by a colour of fill='230'. When I use position='CM' to specify the position of the text, the A' -G230 is shown in the figure. I think the attribute fill='230' have not been correctly parsed.
ff6b8c3c-060b-4295-977a-684e0051dcd6

Minimal Complete Verifiable Example

label = "A\'"
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X4c/4c", frame=True)
fig.text(
    text=label,
    position='CM',
    fill='230'    
)
fig.show()

Full error message

No response

System information

PyGMT information:
  version: v0.11.0
System information:
  python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:33)  [Clang 13.0.1 ]
  executable: /Users/xumijian/miniconda3_arm/bin/python
  machine: macOS-14.2.1-arm64-arm-64bit
Dependency information:
  numpy: 1.24.2
  pandas: 2.2.1
  xarray: 2023.5.0
  netCDF4: 1.6.0
  packaging: 24.0
  contextily: None
  geopandas: None
  ipython: None
  rioxarray: None
  ghostscript: 10.02.1
GMT library information:
  cores: 10
  grid layout: rows
  image layout: 
  library path: /Users/xumijian/miniconda3_arm/lib/libgmt.dylib
  padding: 2
  plugin dir: /Users/xumijian/miniconda3_arm/lib/gmt/plugins
  share dir: /Users/xumijian/miniconda3_arm/share/gmt
  version: 6.3.0
@xumi1993 xumi1993 added the bug Something isn't working label Mar 13, 2024
@seisman
Copy link
Member

seisman commented Mar 13, 2024

I can reproduce the issue. It's the single quote ' that causes the trouble. A temporary workaround is using

label = "A\\047"

@xumi1993
Copy link
Author

Thanks you very much for the temporary solution. Looking forward to the next version solving this issue.

@seisman
Copy link
Member

seisman commented Mar 13, 2024

PR #3105 should fix the issue.

Edit: wait. PR #3105 causes more troubles.

@seisman seisman changed the title Error in pygmt.text triggered by specific conditions Figure.text sometimes doesn't work if the text contains single/double quotation marks Mar 13, 2024
@seisman seisman added this to the 0.12.0 milestone Mar 13, 2024
@seisman seisman removed this from the 0.12.0 milestone Mar 28, 2024
@seisman seisman added this to the 0.12.0 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants