Try to visualize the nutrients of corn flakes that M-1 champion Milkboy said with Python

The story of Milk Boy who won the M-1 Grand Prix the other day

"Cornflakes"

In the episode that appeared in ・ I don't know why the pentagon of nutritional balance is so wide. ・ Because the pentagon written on the package is insanely huge

It is spoken in the story. Let's visualize it with Python immediately.

In Python, with a visualization library called matplotlib Pentagon-like nutrients You can draw a radar chart.

Click here for the code

import matplotlib.pyplot as plt
import pandas as pd
from math import pi
%matplotlib inline

df = pd.DataFrame({
'group'    : ['Corn flakes','Bread'],
'Cal'      : [250,50],
'Fe'       : [260,100],
'VitaminA' : [290,80],
'VitaminB1': [220,60],
'VitaminB2': [305,120],
'Niacin'   : [195,60],
'VitaminC' : [280,85],
'VitaminD' : [280,80],
'VitaminE' : [300,190]
})

categories=list(df)[1:]
N = len(categories)
plt.figure(figsize=(16,9))
ax = plt.subplot(111, polar=True)
angles = [n / float(N) * 2 * pi for n in range(N)] + angles[:1]

#Corn flakes
values = df.loc[0].drop('group').values.flatten().tolist()
values += values[:1]
plt.xticks(angles[:-1], categories, color='grey', size=20)
ax.set_rlabel_position(0)
plt.yticks([100,200,300], ["100","200","300"], color="grey", size=10)
plt.ylim(0,300)
ax.plot(angles, values, linewidth=2, linestyle='solid')
ax.fill(angles, values, 'b', alpha=0.1)

#Bread
values = df.loc[1].drop('group').values.flatten().tolist()
values += values[:1]
plt.xticks(angles[:-1], categories, color='grey', size=20)
ax.set_rlabel_position(0)
plt.yticks([100,200,300], ["100","200","300"], color="green", size=10)
plt.ylim(0,300)
ax.plot(angles, values, linewidth=1, linestyle='solid')
ax.fill(angles, values, 'b', alpha=0.1)

plt.show()

image.png

Create data for display with pandas Just decide the display angle and specify the data to be displayed there It is an easy plot.

Common cornflakes nutrients Because there were many things that were compared with bread I draw bread and corn flakes together.

Nutrient numbers are appropriate

However···

In the first place, the pentagon is different (Utsumi)! !! !!

There was no way that a pentagon was enough for nutrients.

However, the area is insanely large as the story street! !!

It can also be a source of visualization It was a story of a milk boy.

Sure, Milk Boy It goes well with programming.

I'm looking forward to more material coming out.

Recommended Posts

Try to visualize the nutrients of corn flakes that M-1 champion Milkboy said with Python
Try to automate the operation of network devices with Python
Try to image the elevation data of the Geographical Survey Institute with Python
Try to solve the programming challenge book with python3
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
Try to operate DB with Python and visualize with d3
Visualize the range of interpolation and extrapolation with python
Try to get the contents of Word with Golang
Try to create a waveform (audio spectrum) that moves according to the sound with python
I tried to find the entropy of the image with python
Try scraping the data of COVID-19 in Tokyo with Python
Try to get the function list of Python> os package
Try to play with the uprobe that supports Systemtap directly
Visualize the results of decision trees performed with Python scikit-learn
[Python] I tried to visualize the follow relationship of Twitter
Try to import to the database by manipulating ShapeFile of national land numerical information with Python
Try to decipher the garbled attachment file name with Python
Get the source of the page to load infinitely with python.
Try to extract the features of the sensor data with CNN
[Python] Visualize Arashi's lyrics with WordCloud and try to understand what I wanted to convey to fans in the 20th year of formation.
[Python] I tried to visualize the prize money of "ONE PIECE" over 100 million characters with matplotlib.
Try to calculate the position of the transmitter from the radio wave propagation model with python [Wi-Fi, Beacon]
The story that the version of python 3.7.7 was not adapted to Heroku
[Python] Try to graph from the image of Ring Fit [OCR]
A story that struggled to handle the Python package of PocketSphinx
First python ② Try to write code while examining the features of python
Try to solve the N Queens problem with SA of PyQUBO
I want to output the beginning of the next month with Python
Output the contents of ~ .xlsx in the folder to HTML with Python
From the introduction of JUMAN ++ to morphological analysis of Japanese with Python
I tried to improve the efficiency of daily work with Python
Try to solve the shortest path with Python + NetworkX + social data
[python] A note that started to understand the behavior of matplotlib.pyplot
The story of making a module that skips mail with python
[Python] A program that rotates the contents of the list to the left
PhytoMine-I tried to get the genetic information of plants with Python
Try to operate Facebook with Python
How to deal with the problem that build fails when CI / CD of Python Function with AWS Amplify
[Completed version] Try to find out the number of residents in the town from the address list with Python
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
Put Cabocha 0.68 on Windows and try to analyze the dependency with Python
How to crop the lower right part of the image with Python OpenCV
[Python] A program that calculates the number of socks to be paired
[Introduction to Python] How to sort the contents of a list efficiently with list sort
I tried to get the authentication code of Qiita API with Python.
Try to react only the carbon at the end of the chain with SMARTS
I tried to streamline the standard role of new employees with Python
I tried to visualize the text of the novel "Weathering with You" with WordCloud
The result of making the first thing that works with Python (image recognition)
I tried to get the movie information of TMDb API with Python
Address to the bug that node.surface cannot be obtained with python3 + mecab
Try to solve a set problem of high school math with Python
[Cloudian # 5] Try to list the objects stored in the bucket with Python (boto3)
Try to separate the background and moving object of the video with OpenCV
Try to reproduce color film with Python
Try logging in to qiita with Python
Check the existence of the file with python
[Python] Try pydash of the Python version of lodash
Quickly try to visualize datasets with pandas
Python amateurs try to summarize the list ①