Notes on using matplotlib on the server

When drawing on the server side using matplotlib (savefig () etc.)

Traceback 
...
RuntimeError: Invalid DISPLAY variable

You may get angry. This seems to be due to the fact that the display destination DISPLAY is not set. I often see Solution 1, but it's a note when it still doesn't work.

Solution 1

import matplotlib
matplotlib('Agg')
import matplotlib.pyplot as pet

Solution 2

import matplotlib.pyplot as plt
plt.switch_backend('agg')

Recommended Posts

Notes on using matplotlib on the server
Notes on using OpenCL on Linux on the RX6800
Notes on using Alembic
Drawing tips with matplotlib on the server side
[Django] Notes on using django-debug-toolbar
Notes on optimization using Pytorch
Notes on installing Python using PyEnv
Paste the matplotlib figure on excel
Image Optimize on the server side using TinyPNG's Web API
Notes on coloring by value in the matplotlib scatter plot
Notes on installing Ubuntu 18.04 on the XPS 15 7590
(Beginner) Notes on using pyenv on Mac
Notes for using OpenCV on Windows10 Python 3.8.3.
Insufficient var space on the mail server
Notes on using code formatter in Python
Publish the current directory on the web server
Try using matplotlib
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Notes on installing Python3 and using pip on Windows7
Frequently used (personally) notes on the tar command
Notes on using dict in python [Competition Pro]
Write a TCP server using the SocketServer module
Syntax highlighting on the command line using Pygments
Create interactive 3D graphs on JupyterLab using matplotlib
Sound the buzzer using python on Raspberry Pi 3!
Notes for using TensorFlow on Bash on Ubuntu on Windows
Operate Route53 on the command line using AWS-CLI.
Remotely open Jupyter notebook launched on the server
Create a GUI on the terminal using curses
[Python] Notes on accelerating genetic algorithms using multiprocessing
The most crude CORS support method on aiohttp Server
Notes on transactions in the Java client library in the datastore
Set up a file server on Ubuntu 20.04 using Samba
Graph drawing using matplotlib
Celery notes on Django
Try using the temperature sensor (LM75B) on the Raspberry Pi.
I tried using matplotlib
Notes on installing PycURL
Drawing on Jupyter using the plot function of pandas
Post to your account using the API on Twitter
Execute the command on the web server and display the result
Miscellaneous notes about deploying the django app on Heroku
matplotlib legend layout notes
Notes using Python subprocesses
Install django on python + anaconda and start the server
Notes on SciPy.linalg functions
Minimum notes when using Python on Mac (Homebrew edition)
How to know the number of GPUs from python ~ Notes on using multiprocessing with pytorch ~
Notes on the version of CUDA, cuDNN where tensorflow-gpu worked
Notes on building TinyEMU and booting the Linux kernel on Emscripten
Test.py is not reflected on the web server in Python3.
[Hyperledger Iroha] Notes on how to use the Python SDK
I made a VGG16 model using TensorFlow (on the way)
Miscellaneous notes that I tried using python for the matter
To disable the browser cache on Python's simple HTTP server
Notes on how to use marshmallow in the schema library
Install the latest version of Git on your Linux server
I tried to output the access log to the server using Node.js
Python notes using perl-ternary operator
Notes on tf.function and Tracing
Notes on installing dlib on mac