matplotlibloggingxelatexpgf

matplotlib backend pgf version unknown


I'm getting a debug message from matplotlib with the pgf backend:

matplotlib.backends DEBUG backend pgf version unknown

My matplotlib setup is something like

mpl.use("pgf")
mpl.rc('text', usetex=True)
mpl.rcParams['pgf.rcfonts'] = False
mpl.rcParams['pgf.texsystem'] = 'xelatex'
mpl.rcParams["pgf.preamble"] = # xelatex fonts setup and other stuff

Is there a way to silent this message? maybe require a specific pgf version?


Solution

  • In case you want to use logging, but not get any log messages from matplotlib you can do as the documentation states:

    Note that if you want to use logging in your own code, but do not want verbose Matplotlib output, you can set the logging level for Matplotlib independently:

    import logging
    # set DEBUG for everything
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger('matplotlib')
    # set WARNING for Matplotlib
    logger.setLevel(logging.WARNING)
    

    Note that

    matplotlib.backends DEBUG backend pgf version unknown
    

    is a log message, not a warning. It's meant to tell you the version of the backend. However there is no version set for the pgf backend. This is nothing to worry about, unless you would need your application to know such version. In this case I would suggest to use the matplotlib version instead.

    More in detail, backends can set a version. As in backend_bases.py

    backend_version = "unknown"
    

    this is "unknown" in general, but if a certain backend wants to set it, it may. The pgf backend, does not care to do so, which one could consider as a flaw in the code, but such version is usually not really required, as the default backends (like pgf) are part of matplotlib itself, such the matplotlib version itself should give you all needed information for your application.