Home > other >  Failing to use the GTK3Agg Matplotlib backend in Jupyter Notebook
Failing to use the GTK3Agg Matplotlib backend in Jupyter Notebook

Time:02-05

I'm working with Jupyter Notebook (Python 3.9.7, Matplotlib 3.4.3, Anaconda 4.11.0). I'm trying to use the following Matplotlib custom configurations in a Jupyter Notebook:

backend                 :  GTK3Agg    

savefig.dpi             :   300
savefig.format          :   pdf

figure.figsize          :   4,4

xtick.top               :   True
ytick.right             :   True
xtick.minor.visible     :   True
ytick.minor.visible     :   True
ytick.direction         :   in
xtick.direction         :   in
        
xtick.major.size        :   6  # default 3.5
ytick.major.size        :   6  # default 3.5
xtick.minor.size        :   3  # default 2 
ytick.minor.size        :   3  # default 2 

xtick.major.width       :   0.6  # default 0.8
ytick.major.width       :   0.6  # default 0.8
xtick.minor.width       :   0.6  # default 0.6
ytick.minor.width       :   0.6  # default 0.6
axes.linewidth          :   0.6  # default 0.8  
lines.linewidth         :   0.6  # default 1.5 
lines.markeredgewidth   :   0.3  # default 1

xtick.major.pad         :   4  # default 3.5
ytick.major.pad         :   4  # default 3.5 
xtick.minor.pad         :   4  # default 3.5 
ytick.minor.pad         :   4  # default 3.5 

legend.frameon          :   False
legend.handletextpad    :   0.5

text.usetex             :  True     
text.latex.preamble     :  \usepackage{cmbright}

by adding a matplotlibrc file with such content to the directory I'm working in. But I always get the following error when I try to plot something with pyplot:

RuntimeError: latex was not able to process the following string:
b'lp'

Here is the full report generated by latex:
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode

(/home/garpez/.cache/matplotlib/tex.cache/097ed497d104170bb1494fe23d4d7e20.te
x
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/cm-super/type1ec.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmr.fd))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty)))

! LaTeX Error: File `cmbright.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 
         
l.12 \makeatletter
                  \@ifpackageloaded{textcomp}{}{\usepackage{textcomp}}\makea...
No pages of output.

A collegue seems to have the same libraries with the same versions and everything works fine for him. My understanding is that the error I get is related to the latex compiler with the GTK3Agg backend. Like my collegue, I've installed the cairo 1.16.0, latex 0.7.0. What am I doing wrong? I feel that something here is missing.

CodePudding user response:

The issue is not with python, matplotlib or jupyter-notebook, but a LaTeX issue:

LaTeX Error: File `cmbright.sty' not found.

The solution is to install the needed .sty file. In this case, you can either download and extract it from CTAN or you install the package texlive-fonts-extra

sudo apt install texlive-fonts-extra
  •  Tags:  
  • Related