Jul/12/2022 Updated by
Mar/26/2022 Created by
Quick Learning: Matplotlib Tutorial (compatible with Google Colab / Windows / macOS / Linux) by nitta@tsuda.ac.jp
[Up]
Learning Policy
Since matplotlib
is a flexible system, it can be written in various ways, which confuses beginners.
In this article, we will explain how to write matplotlib
programming easily
according to the small number of cardinal rules,
that is, a method with a wide range of applications but less confusion.
Being able to solve various problems with one method is the fastest way
to improve your matplotlib
programming.
Contents
- matplotlib tutorial (1): Understanding the Coordinate System (
Axes
Object) ... html ipynb
- matplotlib tutorial (2): Drawing Line Graphs ... html ipynb
- matplotlib tutorial (3): Using Japanese Font ... html ipynb
- matplotlib tutorial (4): Title and Axis ... html ipynb
- matplotlib tutorial (5): Drawing Texts in the Graph ... html ipynb
- matplotlib tutorial (6): Scatter Diagram, Contour Lines, Filling ... html ipynb
- matplotlib tutorial (7): Saving / loading / Displaying of Images ... html ipynb
- matplotlib tutorial (8): Axis (2) ... html ipynb
- matplotlib tutorial (9): Bar Graph ... html ipynb
- matplotlib tutorial (10): Pi Chart / Circle Graph ... html ipynb
- matplotlib tutorial (11): 3D Graph ... html ipynb
- matplotlib tutorial (12): Bar Graph (2) ... html ipynb
- matplotlib tutorial (13): Animation JSAnimation (compatible with Google Colab) ... html ipynb
- matplotlib tutorial (14): Animation (2) OpenAI Gym Envs (compatible with Google Colab) ... html ipynb
- matplotlib tutorial (15): Understanding the Coordinate System (
Axes
Object) (2) ... html ipynb
Compatibility Check
The versions of OS and python packages when checking the compatibilities are as follows.
html ipynb
Platform | OS version | python | matplotlib | numpy | tensorflow | gym |
Google Colab | Ubuntu 18.04 | 3.7.13 | 3.2.2 | 1.21.6 | 2.8.2 | 0.17.3 |
Windows | Windows 10.0.19043 | 3.10.4 | 3.5.2 | 1.23.1 | 2.9.1 | 0.24.1 |
Mac (intel) | macOS 12.4 Monterey | 3.9.12 | 3.5.2 | 1.23.1 | 2.9.1 | 0.24.1 |
Mac (arm64) | macOS 12.4 Monterey | 3.8.13
miniforge3 | 3.5.2 | 1.23.1 | 2.9.2
tensorflow-metal | 0.25.0 |
Linux (intel) | Ubuntu 22.04 | 3.10.4 | 3.5.2 | 1.23.1 | 2.9.1 | 0.24.1 |
Known Issues
- On Linux (intel), some errors occur at the OpenAI gym in "matplotlib_tutorial_14{,_en}.ipynb". (Jul/12/2022)
- On macOS (arm64), some errors occur at the
anim.save('*.mp4')
in "matplotlib_tutorial_13{,_en}.ipynb". (Jul/12/2022)
The codes below can be executed in the default state.
Execution Environment on Anaconda on Windows / macOS / Linux
- Create a Python virtual environment with the packages installed.
"Anaconda Prompt"(on Windows) or "Terminal"(on macOS or Linux) |
(base) nitta$ conda create -n myenv python jupyter
(base) nitta$ conda activate myenv
(myenv) nitta$ pip install numpy
(myenv) nitta$ pip install matplotlib
(myenv) nitta$ pip install tensorflow
(myenv) nitta$ pip install --user pygame
(myenv) nitta$ pip install gym
(myenv) nitta$ conda deactivate
(base) nitta$
|
- Execute jupyter notebook.
"Anaconda Prompt"(on Windows) or "Terminal" (on macOS or Linux) |
(base) nitta$ conda activate myenv
(myenv) nitta$ jupyter notebook
|
OS Depencencies
On macOS (intel), ffmpeg needs to be installed to save animations as files.
You can install it with the "brew intall ffmpeg
" command using homebrew.
On Linux(intel) , ffmpeg needs to be installed to save animations as files.
You can install it with the "sudo apt update; sudo apt intall ffmpeg
" command on Utuntu Linux.