Last Updated on July 18, 2022 by shibatau
The errors of the codes are corrected.
A Chart of Over 64 for all prefectures are added.
I. Data
You can get the data for Japan’s population projections here:
The survey seems to be conducted every 5 years and the 2018 version is the latest.
You have to upload the four files, kekkahyo1.xls, kekkahyo2_1.xls, kekkahyo2_2.xls, and kekkahyo2_3.xls before running the scripts on Google Colaboratory. You can find all the links to these files on the page linked above.

II. Making a tidy data table
You can learn what a tidy data table is from here:
The tutorial begins with the following fascinating quotations:
“Happy families are all alike; every unhappy family is unhappy in its own way.” –– Leo Tolstoy
“Tidy datasets are all alike, but every messy dataset is messy in its own way.” –– Hadley Wickham
Let’s make the tables tidy:

III. Creating charts


You can create an area charts with pattern fills if you have installed plotly 5.7 or 5.8

You can create a multiple line chart for all the cities in a prefecture:

You can also create a multiple line chart for all the prefectures in Japan:


IV. Scripts
Please put down the names of the city and prefecture that you are interested in and run the scripts here:
https://colab.research.google.com/drive/1SHoknq5fIPr_PB8n9ta2FSrCiPhehMvx?usp=sharing
V. Creating charts with Google Sheets
You can create charts using Google Sheets. You can also add a column of the names translated with GOOGLETRANSLATE( ) like this.

You can see a sample sheet here: