[PYTHON] Create a poster with matplotlib to visualize multiplication tables that remember multiplication

There is a "multiplication table", isn't it? This is the one when children learn multiplication in Japan.

"Inichi gaichi, innigani, insan gasan," is the one.

The multiplication table is convenient for learning multiplication, but I heard the opinion that "You can't just remember the pun. You have to understand the meaning of multiplication." So I made a poster that can understand the meaning of multiplication as well. I made it with matplotlib. It took about 30 minutes to code.

Installation and import of matploblib for Japanese

!pip install japanize-matplotlib
Collecting japanize-matplotlib
[?25l  Downloading https://files.pythonhosted.org/packages/aa/85/08a4b7fe8987582d99d9bb7ad0ff1ec75439359a7f9690a0dbf2dbf98b15/japanize-matplotlib-1.1.3.tar.gz (4.1MB)
      |████████████████████████████████| 4.1MB 5.5MB/s 
[?25hRequirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from japanize-matplotlib) (3.2.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->japanize-matplotlib) (1.3.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->japanize-matplotlib) (2.8.1)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->japanize-matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->japanize-matplotlib) (2.4.7)
Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.6/dist-packages (from matplotlib->japanize-matplotlib) (1.19.5)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil>=2.1->matplotlib->japanize-matplotlib) (1.15.0)
Building wheels for collected packages: japanize-matplotlib
  Building wheel for japanize-matplotlib (setup.py) ... [?25l[?25hdone
  Created wheel for japanize-matplotlib: filename=japanize_matplotlib-1.1.3-cp36-none-any.whl size=4120276 sha256=642a1577ef5e695d7ef7a5fc14e07ad45d62ab853ca64da221873f69938f3e6c
  Stored in directory: /root/.cache/pip/wheels/b7/d9/a2/f907d50b32a2d2008ce5d691d30fb6569c2c93eefcfde55202
Successfully built japanize-matplotlib
Installing collected packages: japanize-matplotlib
Successfully installed japanize-matplotlib-1.1.3
import matplotlib.pyplot as plt
import japanize_matplotlib 

Drawing of multiplication table poster

fig, axes = plt.subplots(nrows=9, ncols=9, figsize=(16, 16))
for x in range(9):
    for y in range(9):
        axes[y][x].axis("off")
        axes[y][x].set_aspect("equal")
        axes[y][x].set_title("{} x {} = {}".format(x + 1, y + 1, (x + 1) * (y + 1)))
        axes[y][x].set_xlim([0, 11])
        axes[y][x].set_ylim([0, 11])
        X = []
        Y = []
        for i in range(x + 1):
            for j in range(y + 1):
                X.append(i + 2)
                Y.append(10 - j - 1)
        axes[y][x].scatter(X, Y)

plt.savefig("300_dpi_scatter.png ", format="png", dpi=300)

300_dpi_scatter.png

The order of multiplication?

By the way, it seems that teachers who care about the order of multiplication are talking about on Twitter etc., but is there anything to say about this?

Mouse version

My kids love the mice, so I made a mouse version as well.

fig, axes = plt.subplots(nrows=9, ncols=9, figsize=(28, 28))
for x in range(9):
    for y in range(9):
        axes[y][x].axis("off")
        axes[y][x].set_aspect("equal")
        axes[y][x].set_title("{} x {} = {}".format(x + 1, y + 1, (x + 1) * (y + 1)), fontsize=20)
        axes[y][x].set_xlim([-1, 11])
        axes[y][x].set_ylim([-1, 11])
        X = []
        Y = []
        for i in range(x + 1):
            for j in range(y + 1):
                X.append(i + 2)
                Y.append(10 - j - 1)
        if (x + 1) * (y + 1) % 2 == 1:
            c = 'k'
        else:
            c = 'r'
        axes[y][x].scatter(X, Y, c=c, s=28, marker='o')
        axes[y][x].scatter([xx + 0.25 for xx in X], [yy + 0.25 for yy in Y], c=c, s=12, marker='o')
        axes[y][x].scatter([xx - 0.25 for xx in X], [yy + 0.25 for yy in Y], c=c, s=12, marker='o')

plt.savefig("300_dpi_scatter.png ", format="png", dpi=300)

300_dpi_scatter (1).png

If the result of the multiplication is odd, I made it black, and if it was even, I made it red. Haha ♪

Recommended Posts

Create a poster with matplotlib to visualize multiplication tables that remember multiplication
I want to manually create a legend with matplotlib
[Python] How to create a 2D histogram with Matplotlib
Generate a password that is easy to remember with apg
Create a graph with borders removed with matplotlib
How to draw a bar graph that summarizes multiple series with matplotlib
Create a page that loads infinitely with python
Steps to create a Twitter bot with python
Visualize grib2 on a map with python (matplotlib)
Create a stacked graph corresponding to both positive and negative directions with matplotlib
I tried to create a table only with Django
Create a function to visualize / evaluate the clustering result
[Python] How to draw a line graph with Matplotlib
Try to create a battle record table with matplotlib from the data of "Schedule-kun"
How to create a submenu with the [Blender] plugin
Try to dynamically create a Checkbutton with Python's Tkinter
Create a chatbot that supports free input with Word2Vec
Try to create a waveform (audio spectrum) that moves according to the sound with python
[Python] How to draw a scatter plot with Matplotlib
[Python] Road to a snake charmer (5) Play with Matplotlib
A script that makes it easy to create rich menus with the LINE Messaging API
Steps to create a Job that pulls a Docker image and tests it with Github Actions
Let's create a program that automatically registers ID/PW from CSV to Bitwarden with Python + Selenium
A program that failed when trying to create a linebot with reference to "Dialogue system made with python"
Create a web application that recognizes numbers with a neural network
Create a PythonBox that outputs with Random after PEPPER Input
I tried to automatically create a report with Markov chain
Create a Mastodon bot with a function to automatically reply with Python
Let's create a script that registers with Ideone.com in Python.
Probably the easiest way to create a pdf with Python3
Create a life game that is manually updated with tkinter
Let's create a PRML diagram with Python, Numpy and matplotlib.
How to create a flow mesh around a cylinder with snappyHexMesh
Tornado-Let's create a Web API that easily returns JSON with JSON
Create a message corresponding to localization with python translation string
Create a homepage with django
Create a heatmap with pyqtgraph
Create a directory with python
I want to create a graph with wavy lines omitted in the middle with matplotlib (I want to manipulate the impression)
I tried to create a server environment that runs on Windows 10
Create a program that can generate your favorite images with Selenium
I want to use a wildcard that I want to shell with Python remove
I wanted to create a smart presentation with Jupyter Notebook + nbpresent
[Python] A memo that I tried to get started with asyncio
Try to create a python environment with Visual Studio Code & WSL
Qiskit: I want to create a circuit that creates arbitrary states! !!
Rails users try to create a simple blog engine with Django
I tried to create a list of prime numbers with python
How to create a heatmap with an arbitrary domain in Python
How to create a label (mask) for segmentation with labelme (semantic segmentation mask)
[LINE Messaging API] Create a BOT that connects with someone with Python
I tried to create Bulls and Cows with a shell program
How to write a docstring to create a named tuple document with sphinx
Try to create a Qiita article with REST API [Environmental preparation]
Create a REST API to operate dynamodb with the Django REST Framework
How to create a serverless machine learning API with AWS Lambda
Create plot animation with Python + Matplotlib
A python graphing manual with Matplotlib.
Create folders from '01' to '12' with python
Draw a loose graph with matplotlib
How to create a Conda package