To run matplotlib there are a few setup parameters that are needed.

 

1.) Make sure that xorg-x11-server-Xvfb is installed on all compute nodes being used.

2.) Make sure that a display is initiated with this command:

Xvfb :1 -screen 0 1024x768x24 &

 

3.) In your script, two environment variables need to be setup.

export DISPLAY=:1
export FONTCONFIG_FILE=/etc/fonts/fonts.conf