Search code examples
pythonmatplotlibipythonxservertiling

Adding a XClass properties to matplotlib's plots


I would like to have the window manager to, well, manage the plots. When I create a plot interactively in python:

from numpy import arange
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as pt
pt.ion()

x = arange(-10,10,step=.1)
pt.plot(x, x**3)

And check for the window properties, I get nothing.

% xprop | grep CLASS
WM_CLASS(STRING) = " ", " "

How can I tell matplotlib/Python to add X-window properties to its plots?


Solution

  • As it appears, this is not a problem of matplotlib nor is matplotlib the solution: Instead the backends seem to be responsible for creating the window clients and do the registration and settings of X.org-properties.

    Having switched from Qt5Agg to TkAgg, I suddenly have all the properties I could wish for:

    % xprop | grep CLASS
    WM_CLASS(STRING) = "tk", "Tk"
    % xprop | grep WM_NAME
    _NET_WM_NAME(UTF8_STRING) = "Figure 1"
    WM_NAME(STRING) = "Figure 1"
    

    My window manager (herbstluftwm) is now handling all newly created figures nicely.