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] Japanese English

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


Compatibility Check

The versions of OS and python packages when checking the compatibilities are as follows.    html    ipynb
PlatformOS versionpythonmatplotlibnumpytensorflowgym
Google ColabUbuntu 18.043.7.133.2.21.21.62.8.20.17.3
WindowsWindows 10.0.190433.10.43.5.21.23.12.9.10.24.1
Mac (intel)macOS 12.4 Monterey3.9.123.5.21.23.12.9.10.24.1
Mac (arm64)macOS 12.4 Monterey3.8.13
miniforge3
3.5.21.23.12.9.2
tensorflow-metal
0.25.0
Linux (intel)Ubuntu 22.043.10.43.5.21.23.12.9.10.24.1

Known Issues

  1. On Linux (intel), some errors occur at the OpenAI gym in "matplotlib_tutorial_14{,_en}.ipynb". (Jul/12/2022)
  2. On macOS (arm64), some errors occur at the anim.save('*.mp4') in "matplotlib_tutorial_13{,_en}.ipynb". (Jul/12/2022)

Execution Environment on Google Colabe

The codes below can be executed in the default state.

Execution Environment on Anaconda on Windows / macOS / Linux

  1. Create a Python virtual environment with the packages installed.
  2. "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$ 
    
  3. Execute jupyter notebook.
  4. "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.