[Short note] In matplotlib, nothing is displayed even if I show it → Check the backend setting

The backend may not be GUI.

python


import matplotlib as mpl
mpl.use('tkagg')

Is evaluated before import matplotlib.pyplot` (written in the line above).

** ʻImport Error: No module named backend_tkagg.pyis displayed: ** It looks like the backend is not installed. Installation is required with apt-get or yum. For SUSE sudo zypper in python-matplotlib-tk` (python3-matplotlib-tk for Python3)

** Now I can do it, but it's a hassle to do this every time ** Describe in the matplotlibrc file.

~/.config/matplotlib/matplotlibrc


backend : tkagg

For Linux, .config/matplotlib/matplotlibrc On other platforms, .matplotlib/matplotlibrc If you don't know

python


import matplotlib as mpl
print(mpl.get_configdir() + '/matplotlibrc')

reference

http://python.dogrow.net/?p=186 http://matplotlib.org/users/customizing.html

Recommended Posts

[Short note] In matplotlib, nothing is displayed even if I show it → Check the backend setting
Check if it is Unix in the scripting language
Check if it is Unix in the scripting language
The date is displayed incorrectly in matplotlib.
Even if the development language is changed to python3 in Cloud9, version 2 is displayed in python --version
Check if the string is a number in python
What to do when only the window is displayed and nothing is displayed in pygame Note
(Note) I'll do a Django tutorial. Even if I follow the site, it doesn't work.
What to do if the image is not displayed using matplotlib etc. in the Docker container
I made a function to check if the webhook is received in Lambda for the time being
Check if the configuration file is read in an easy-to-understand manner
Delete a particular character in Python if it is the last
[Golang] Check if a specific character string is included in the character string
I set the environment variable with Docker and displayed it in Python
If the conda environment is strange, let's put it back in mac
I created a script to check if English is entered in the specified position of the JSON file in Python.
Check if the URL exists in Python
Note that I understand the least squares algorithm. And I wrote it in Python.
[For beginners] Unexpected behavior if "\" is included when setting the path in Python