Thanks to visit codestin.com
Credit goes to github.com

Skip to content

~ in mathrm leads to Unknown symbol: \mathrm #12946

Closed
@smithsp

Description

@smithsp

Bug report

Bug summary

Trying to add a label with a LaTeX math section with a mathrm section with a ~ in the argument of mathrm leads to an error. My apologies if this bug has already been reported; I couldn't find one searching the issues for mathrm.

Code for reproduction

plot([0,1])
xlabel(r'$\mathrm{1\ 2}$')

Actual outcome

>>> from pylab import *
>>> plot([0,1])
[<matplotlib.lines.Line2D object at 0x2ace301cfb10>]
>>> xlabel(r'$\mathrm{1~2}$')
Text(0.5,0,'$\\mathrm{1~2}$')
>>> show()
Traceback (most recent call last):
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
    self.draw()
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 437, in draw
    self.figure.draw(self.renderer)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/figure.py", line 1493, in draw
    renderer, self, artists, self.suppressComposite)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2635, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/axis.py", line 1204, in draw
    self.label.draw(renderer)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/text.py", line 706, in draw
    bbox, info, descent = textobj._get_layout(renderer)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/text.py", line 309, in _get_layout
    ismath=ismath)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 241, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/mathtext.py", line 3293, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
  File "/fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2/lib/python2.7/site-packages/matplotlib/mathtext.py", line 2521, in parse
    six.text_type(err)]))
ValueError: 
\mathrm{1~2}
^
Unknown symbol: \mathrm (at char 0), (line:1, col:1)

Expected outcome

No error.

Matplotlib version

  • Operating system:
> uname -a
Linux irisd.cluster 2.6.32-696.30.1.el6.x86_64 #1 SMP Tue May 22 03:28:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Matplotlib version: 2.2.3
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version:
> python -V
Python 2.7.14 :: Anaconda, Inc.
  • Other libraries:
> conda list
# packages in environment at /fusion/projects/codes/atom/omfit_v1/atom_SATURN_GCC/miniconda2:
#
# Name                    Version                   Build  Channel
_tflow_select             2.2.0                     eigen  
absl-py                   0.2.2                      py_0    conda-forge
alabaster                 0.7.11                     py_3    conda-forge
anaconda-client           1.6.14                     py_0    conda-forge
apptools                  4.4.0                      py_1    conda-forge
asn1crypto                0.24.0                   py27_0  
asteval                   0.9.12             pyh24bf2e0_1    conda-forge
astor                     0.7.1                      py_0    conda-forge
astropy                   2.0.8                    py27_0    conda-forge
atk                       1.28.0                        0    ska
atomicwrites              1.1.5                    py27_0    conda-forge
attrs                     18.1.0                     py_1    conda-forge
awscli                    1.15.59                  py27_0    conda-forge
babel                     2.6.0                      py_1    conda-forge
backports                 1.0                      py27_1    conda-forge
backports.functools_lru_cache 1.5                        py_1    conda-forge
backports.shutil_get_terminal_size 1.0.0                      py_3    conda-forge
backports.weakref         1.0.post1                py27_0    conda-forge
backports_abc             0.5                      py27_0    conda-forge
basemap                   1.2.0            py27h50ae964_0    conda-forge
beautifulsoup4            4.6.0                    py27_0    conda-forge
bibtexparser              1.0.1                      py_1    conda-forge
blas                      1.0                         mkl  
bleach                    1.5.0                    py27_0    conda-forge
blosc                     1.14.4               hfc679d8_0    conda-forge
bokeh                     0.13.0                   py27_0    conda-forge
boto3                     1.7.58                     py_0    conda-forge
botocore                  1.10.58                    py_0    conda-forge
bottleneck                1.2.1            py27h7eb728f_1    conda-forge
bzip2                     1.0.6                h470a237_2    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
cairo                     1.8.8                         0    ska
certifi                   2018.11.29            py27_1000    conda-forge
cffi                      1.11.5           py27h9745a5d_0  
cftime                    1.0.1            py27h7eb728f_0    conda-forge
chaospy                   2.3.3                      py_0    conda-forge
chardet                   3.0.4            py27hfa10054_1  
click                     6.7                        py_1    conda-forge
cloudpickle               0.5.3                      py_0    conda-forge
clyent                    1.2.2                      py_1    conda-forge
colorama                  0.3.9                      py_1    conda-forge
conda                     4.5.11                py27_1000    conda-forge
conda-build               3.10.9                   py27_0    conda-forge
conda-env                 2.6.0                h36134e3_1  
conda-verify              2.0.0                    py27_0    conda-forge
configobj                 5.0.6                    py27_0  
contextlib2               0.5.5                      py_2    conda-forge
corner                    2.0.1                    py27_0    conda-forge
cryptography              2.2.2            py27h14c3975_0  
cudatoolkit               9.2                           0  
cudnn                     7.2.1                 cuda9.2_0  
cupti                     9.2.148                       0  
curl                      7.60.0                        0    conda-forge
cycler                    0.10.0                     py_1    conda-forge
cyordereddict             1.0.0                    py27_1    conda-forge
cython                    0.28.5           py27hfc679d8_0    conda-forge
cytoolz                   0.9.0.1          py27h470a237_0    conda-forge
dask                      0.18.1                     py_0    conda-forge
dask-core                 0.18.1                     py_0    conda-forge
dbus                      1.13.0               h3a4f0e9_0    conda-forge
decorator                 4.3.0                      py_0    conda-forge
dicttoxml                 1.7.4                    py27_0    conda-forge
dill                      0.2.8.2                  py27_0    conda-forge
distributed               1.22.0                   py27_0    conda-forge
docutils                  0.14                     py27_0    conda-forge
emcee                     2.2.1              pyh24bf2e0_4    conda-forge
enum34                    1.1.6            py27h99a27e9_1  
envisage                  4.5.1                      py_1    conda-forge
expat                     2.2.6                he6710b0_0  
fann2                     2.2.0                         0    conda-forge
ffmpeg                    3.4.1                         0    conda-forge
fftw2                     2.1.5                         0    smithsp
filelock                  3.0.4                      py_1    conda-forge
fontconfig                2.13.0               h9420a91_0  
fortranformat             0.2.5                      py_0    conda-forge
freeglut                  3.0.0                         4    conda-forge
freetds                   1.00.9                        0    smithsp
freetype                  2.9.1                h6debe1e_4    conda-forge
funcsigs                  1.0.2                      py_2    conda-forge
functools32               3.2.3.2                  py27_2    conda-forge
future                    0.16.0                     py_1    conda-forge
futures                   3.2.0            py27h7b459c0_0  
gast                      0.2.0                      py_0    conda-forge
geos                      3.6.2                hfc679d8_2    conda-forge
gettext                   0.19.8.1                      0    conda-forge
git                       2.18.0                        0    conda-forge
gitdb2                    2.0.5                      py_0    conda-forge
gitpython                 2.1.11                     py_0    conda-forge
glib                      2.55.0                        0    conda-forge
glob2                     0.6                        py_0    conda-forge
gmp                       6.1.2                hfc679d8_0    conda-forge
gnutls                    3.5.19               h2a4e5f8_1    conda-forge
gpr1d                     1.0.2                      py_0    aaronkho
gpr1dfusion               1.0.1                      py_0    aaronkho
gptools                   0.2.3            py27h7eb728f_0    conda-forge
grpcio                    1.12.1           py27hdbcaa40_0  
gst-plugins-base          1.12.5               hde13a9d_0    conda-forge
gstreamer                 1.12.5               h61a6719_0    conda-forge
h5netcdf                  0.6.2                      py_0    conda-forge
h5py                      2.8.0            py27hb794570_1    conda-forge
hdf4                      4.2.13                        0    conda-forge
hdf5                      1.10.2               hc401514_2    conda-forge
heapdict                  1.0.0                    py27_0    conda-forge
html5lib                  0.9999999                py27_0    conda-forge
icu                       58.2                 hfc679d8_0    conda-forge
idna                      2.6              py27h5722d68_1  
imagesize                 1.0.0                      py_1    conda-forge
imbalanced-learn          0.3.3                      py_0    conda-forge
intel-openmp              2018.0.3                      0  
ipaddress                 1.0.22                   py27_0  
ipython                   5.7.0                    py27_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.12.1                   py27_0    conda-forge
jinja2                    2.10                       py_1    conda-forge
jmespath                  0.9.3                      py_1    conda-forge
jpeg                      9c                   h470a237_0    conda-forge
jsoncpp                   1.8.4                h2d50403_0    conda-forge
jsonschema                2.6.0                    py27_1    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
keras                     2.1.6                    py27_0    conda-forge
keras-applications        1.0.6                    py27_0  
keras-preprocessing       1.0.5                      py_0    conda-forge
kiwisolver                1.0.1                    py27_1    conda-forge
krb5                      1.14.6                        0    conda-forge
libcurl                   7.61.0               h1ad7b7a_0  
libedit                   3.1.20170329         h6b74fdf_2  
libffi                    3.2.1                hd88cf55_4  
libgcc                    4.8.5                         2  
libgcc-ng                 8.2.0                hdf63c60_1  
libgfortran               3.0.0                         1  
libgfortran-ng            7.2.0                hdf63c60_3  
libgpuarray               0.7.6                h470a237_3    conda-forge
libiconv                  1.15                 h470a237_1    conda-forge
libnetcdf                 4.6.1                he6cff42_8    conda-forge
libogg                    1.3.2                h470a237_1    conda-forge
libopenblas               0.2.20               h9ac9557_7  
libpng                    1.6.34               ha92aebf_1    conda-forge
libpq                     9.6.3                         0    conda-forge
libprotobuf               3.6.1                hd28b015_0    conda-forge
libssh2                   1.8.0                h5b517e9_2    conda-forge
libstdcxx-ng              8.2.0                hdf63c60_1  
libtheora                 1.1.1                h470a237_1    conda-forge
libtiff                   4.0.9                he6b73bb_1    conda-forge
libuuid                   1.0.3                         1    conda-forge
libvorbis                 1.3.5                h470a237_1    conda-forge
libxcb                    1.13                 h470a237_1    conda-forge
libxml2                   2.9.8                h422b904_2    conda-forge
linecache2                1.0.0                    py27_0    conda-forge
llvmlite                  0.23.0                   py27_1    conda-forge
lmfit                     0.9.11             pyh24bf2e0_1    conda-forge
locket                    0.2.0                    py27_1    conda-forge
lz4-c                     1.8.3                hfc679d8_0    conda-forge
lzo                       2.10                          0    conda-forge
mako                      1.0.7                      py_1    conda-forge
markdown                  2.6.11                     py_0    conda-forge
markupsafe                1.0                      py27_0    conda-forge
matplotlib                2.2.3            py27h8e2386c_0    conda-forge
mayavi                    4.6.2            py27h18b3941_1    conda-forge
mdsplus                   7.7.9            py27hf484d3e_2    omfit
mkl                       2018.0.3                      1  
mkl_fft                   1.0.6                    py27_0    conda-forge
mkl_random                1.0.1                    py27_0    conda-forge
mock                      2.0.0                    py27_0    conda-forge
more-itertools            4.2.0                    py27_1    conda-forge
mpi                       1.0                       mpich    conda-forge
mpi4py                    3.0.0              py27_mpich_3    conda-forge
mpich                     3.2.1                h26a2512_4    conda-forge
mpmath                    1.0.0                      py_0    conda-forge
msgpack-python            0.5.6            py27h2d50403_2    conda-forge
nbformat                  4.4.0                    py27_0    conda-forge
ncurses                   6.1                  hf484d3e_0  
netcdf4                   1.4.1            py27h62672b6_0    conda-forge
nettle                    3.3                           0    conda-forge
networkx                  2.1                        py_1    conda-forge
nlopt                     2.5.0            py27hf8a1672_0    conda-forge
numba                     0.38.1                   py27_0    conda-forge
numeric                   24.2                     py27_0    smithsp
numexpr                   2.6.6                    py27_0    conda-forge
numpy                     1.15.1           py27h1d66e8a_0  
numpy-base                1.15.1           py27h81de0dd_0  
omas                      0.28.0                     py_0    conda-forge
omfit                     0.25.8.10                py27_1    omfit
omfit                     0.0.0                     <pip>
openblas                  0.2.20                        8    conda-forge
openh264                  1.7.0                         0    conda-forge
openssl                   1.0.2o               h470a237_1    conda-forge
packaging                 17.1                       py_0    conda-forge
pact                      10_08_25                 py27_0    omfit
pandas                    0.23.4           py27hf8a1672_0    conda-forge
pango                     1.26.0                        0    ska
parso                     0.3.0                      py_0    conda-forge
partd                     0.3.8                      py_1    conda-forge
patchelf                  0.9                           2    conda-forge
pathlib2                  2.3.2                    py27_0    conda-forge
patsy                     0.5.0                      py_1    conda-forge
pbr                       4.1.0                      py_0    conda-forge
pcre                      8.41                          1    conda-forge
pexpect                   4.6.0                    py27_0    conda-forge
pickleshare               0.7.4                    py27_0    conda-forge
pidly                     0.2.7                    py27_0    conda-forge
pint                      0.8.1                      py_1    conda-forge
pip                       10.0.1                   py27_0  
pixman                    0.16.2                        0    ska
pkginfo                   1.4.2                      py_1    conda-forge
pluggy                    0.6.0                      py_0    conda-forge
postgresql                9.6.3                         3    conda-forge
prompt_toolkit            1.0.15                   py27_0    conda-forge
protobuf                  3.6.1            py27hfc679d8_1    conda-forge
psutil                    5.4.6                    py27_0    conda-forge
psycopg2                  2.7.5                    py27_0    conda-forge
pthread-stubs             0.4                  h470a237_1    conda-forge
ptyprocess                0.6.0                    py27_0    conda-forge
py                        1.5.4                      py_0    conda-forge
py-fann2                  1.1.2            py27h470a237_0    conda-forge
pyasn1                    0.4.4                      py_1    conda-forge
pycosat                   0.6.3            py27ha4109ae_0  
pycparser                 2.18             py27hefa08c5_1  
pydatautils               2.16.30                  py27_1    omfit
pyface                    6.0.0                      py_1    conda-forge
pyfftw2                   2.6.26                   py27_0    omfit
pygments                  2.2.0                      py_1    conda-forge
pygpu                     0.7.6            py27h7eb728f_0    conda-forge
pymssql                   2.1.3.post16             py27_0    conda-forge
pyodbc                    4.0.17                   py27_0    conda-forge
pyopenssl                 18.0.0                   py27_0  
pyotp                     2.2.6                    py27_0    omfit
pyparsing                 2.2.0                      py_1    conda-forge
pyproj                    1.9.4                    py27_0    conda-forge
pyqt                      5.6.0            py27h8210e8a_6    conda-forge
pyshp                     2.0.0                      py_0    conda-forge
pysocks                   1.6.8                    py27_0  
pytables                  3.4.4            py27h4f72b40_1    conda-forge
pytest                    3.6.3                    py27_0    conda-forge
python                    2.7.14              h1571d57_29  
python-dateutil           2.7.3                      py_0    conda-forge
pyttk                     0.3.2                      py_0    conda-forge
pytz                      2018.5                     py_0    conda-forge
pyyaml                    3.12                     py27_1    conda-forge
qt                        5.6.2                hf70d934_9    conda-forge
readline                  7.0                  ha6073c6_4  
reindent                  0.1.1                    py27_0    conda-forge
requests                  2.20.1                py27_1000    conda-forge
rsa                       3.4.2                      py_1    conda-forge
ruamel_yaml               0.15.37          py27h14c3975_2  
s3transfer                0.1.13                   py27_0    conda-forge
scandir                   1.7              py27h470a237_1    conda-forge
scikit-learn              0.19.1           py27hedc7406_0  
scikit-optimize           0.5.2                      py_0    conda-forge
scipy                     1.1.0            py27hc49cb51_0  
seaborn                   0.9.0                      py_0    conda-forge
setuptools                39.2.0                   py27_0  
shapely                   1.6.4            py27h164cb2d_1    conda-forge
simplegeneric             0.8.1                      py_1    conda-forge
singledispatch            3.4.0.3                  py27_0    conda-forge
sip                       4.18                     py27_1    conda-forge
six                       1.11.0           py27h5f960f1_1  
smmap2                    2.0.5                      py_0    conda-forge
snowballstemmer           1.2.1                      py_1    conda-forge
sortedcontainers          2.0.4                      py_1    conda-forge
sphinx                    1.6.7                    py27_0    conda-forge
sphinx_bootstrap_theme    0.6.4                      py_0    conda-forge
sphinxcontrib-websupport  1.0.1                    py27_0    conda-forge
sqlite                    3.24.0               h2f33b56_1    conda-forge
statsmodels               0.9.0                    py27_0    conda-forge
subprocess32              3.5.2                    py27_0    conda-forge
tbb                       2019.2               h2d50403_0    conda-forge
tblib                     1.3.2                      py_1    conda-forge
tensorboard               1.12.0                py27_1000    conda-forge
tensorflow                1.12.0          eigen_py27hfe19c55_0  
tensorflow-base           1.12.0          eigen_py27h4dcebc2_0  
termcolor                 1.1.0                      py_2    conda-forge
theano                    1.0.3            py27hfc679d8_1    conda-forge
tk                        8.6.9                ha92aebf_0    conda-forge
toolchain                 2.3.0                         0    conda-forge
toolchain_c_linux-64      2.3.0                         0    conda-forge
toolchain_cxx_linux-64    2.3.0                         0    conda-forge
toolz                     0.9.0                      py_0    conda-forge
tornado                   5.1                      py27_0    conda-forge
traceback2                1.4.0                    py27_0    conda-forge
traitlets                 4.3.2                    py27_0    conda-forge
traits                    4.6.0            py27h470a237_2    conda-forge
traitsui                  6.0.0                      py_1    conda-forge
typing                    3.6.4                    py27_2    conda-forge
uncertainties             3.0.2                    py27_1    conda-forge
unittest2                 1.1.0                      py_0    conda-forge
unixodbc                  2.3.4                         0    smithsp
urllib3                   1.22             py27ha55213b_0  
vtk                       8.1.1           py27h4f1983a_204  
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5                      py27_0    conda-forge
werkzeug                  0.14.1                     py_0    conda-forge
wget                      1.19.5               h1ad7b7a_0  
wheel                     0.31.1                   py27_0  
x264                      1!152.20180717       h470a237_0    conda-forge
xarray                    0.10.8                   py27_0    conda-forge
xorg-kbproto              1.0.7                h470a237_2    conda-forge
xorg-libice               1.0.9                h470a237_3    conda-forge
xorg-libsm                1.2.2                h470a237_3    conda-forge
xorg-libx11               1.6.5                h470a237_1    conda-forge
xorg-libxau               1.0.8                h470a237_5    conda-forge
xorg-libxdmcp             1.1.2                h470a237_6    conda-forge
xorg-libxext              1.3.3                h470a237_3    conda-forge
xorg-libxmu               1.1.2                h470a237_1    conda-forge
xorg-libxp                1.0.3                         0    conda-forge
xorg-libxrender           0.9.10               h470a237_1    conda-forge
xorg-libxt                1.1.5                h470a237_1    conda-forge
xorg-renderproto          0.11.1               h470a237_2    conda-forge
xorg-xextproto            7.3.0                h470a237_2    conda-forge
xorg-xproto               7.0.31               h470a237_7    conda-forge
xz                        5.2.4                h470a237_1    conda-forge
yaml                      0.1.7                had09818_2  
zict                      0.1.3                      py_0    conda-forge
zlib                      1.2.11               ha838bed_2  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions