Skip to content

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

Closed

Description

@xumi1993

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

Activity

  1. added
    bug
    on Mar 13, 2024
  2. seisman commented on Mar 13, 2024

    @seisman
    Member

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

    label = "A\\047"
    
  3. xumi1993 commented on Mar 13, 2024

    @xumi1993
    Author

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

  4. seisman commented on Mar 13, 2024

    @seisman
    Member

    PR #3105 should fix the issue.

    Edit: wait. PR #3105 causes more troubles.

  5. 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[/+] on Mar 13, 2024
  6. added this to the 0.12.0 milestone on Mar 13, 2024
  7. removed this from the 0.12.0 milestone on Mar 28, 2024
  8. added this to the 0.12.0 milestone on Apr 18, 2024
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions