As seen in many bugs the presents of ~/.config/matplotlib for the user you are compiling the package with, causes sandbox violations as soon as matplotlib comes into play. This can be worked around by setting XDG_CONFIG_HOME to e.g. $T How about proactivaly setting this in the python*r1 eclasses instead of waiting for a user filing a bug when hitting this. Additionally we could also set MPLCONFIGDIR to avoid checking in users directory.
I sent a note to gentoo-dev asking for advice.
Ideally this would be dealt with by Portage, but it looks like that's going to get caught up in the usual EAPI lag time.
same problem with mpv
xdg.eclass was added by Gilles some weeks ago for this kind of issue (and yes, I would also like to see this done at PM level for not needing to keep adding xdg.eclass to random ebuilds when bugs are reported but, until that is done...)
This looks tracker-ish, and it seems that all tracked bugs have been fixed. The only remaining point is to have ENV_UNSET from EAPI 7 implemented and in use.