Skip to content

The fig.text function in PyGMT does not plot text if the text is purely numeric in pygmt 0.14.1 #3803

@naveenragur

Description

@naveenragur

Description of the problem

Problem: The fig.text function in PyGMT does not plot text if the text is purely numeric.

Steps to Reproduce:
Create a PyGMT figure.
Use the fig.text function to plot a numeric string (e.g., "12345").
Observe that the numeric text does not appear on the plot.

Expected Behavior: The numeric text should be plotted on the figure.

Actual Behavior: The numeric text does not appear on the figure.

Minimal Complete Verifiable Example

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True)
fig.text(x=5, y=5, text="12345")  # Numeric text
fig.show()
#doesnt plot text and raises error message

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True)
fig.text(x=5, y=5, text="12345a")  # Numeric text
fig.show()
#plots text as expected

Full error message

text [ERROR]: Text record line 0 is NULL! Skipped but this is trouble)

System information

PyGMT information:
  version: v0.14.1
System information:
  python: 3.13.1 | packaged by conda-forge | (main, Jan 13 2025, 09:53:10) [GCC 13.3.0]
  executable: /home/nrr/miniconda3/envs/pygmt/bin/python
  machine: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
Dependency information:
  numpy: 2.2.2
  pandas: 2.2.3
  xarray: 2025.1.2
  netCDF4: 1.7.2
  packaging: 24.2
  contextily: 1.6.2
  geopandas: 1.0.1
  IPython: 8.32.0
  pyarrow: 19.0.0
  rioxarray: 0.18.2
  gdal: 3.10.1
  ghostscript: 10.04.0
GMT library information:
  version: 6.5.0
  padding: 2
  share dir: /home/nrr/miniconda3/envs/pygmt/share/gmt
  plugin dir: /home/nrr/miniconda3/envs/pygmt/lib/gmt/plugins
  library path: /home/nrr/miniconda3/envs/pygmt/lib/libgmt.so
  cores: 20
  grid layout: rows
  image layout: 
  binary version: 6.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions