1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

M-1王者ミルクボーイの言っていたコーンフレークの栄養素の可視化をPythonで試みてみる

Posted at

先日のM-1グランプリで優勝したミルクボーイさんのネタ

「コーンフレーク」

に出てきたエピソードで
・なんであんなに、栄養バランスの五角形が広いんかわからん
・パッケージに書いてる五角形めちゃくちゃでかいんやから

なーんてネタ中で語られています。
早速Pythonで可視化してみましょう。

Pythonではmatplotlibという可視化のライブラリで
栄養素の五角形っぽい
レーダーチャートを描くことが出来ます。

コードはこちら

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

df = pd.DataFrame({
'group'    : ['コーンフレーク','パン'],
'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]

# コーンフレーク
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)

# パン
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

表示用のデータをpandasで作り
表示アングルを決め、そこに表示するデータを指定するだけの
簡単plotになっています。

一般的なコーンフレークの栄養素は
パンとかと比較されているモノが多かったので
パンとコーンフレークを併せて描画してます。

栄養素の数値は適当です

しかし・・・

そもそも五角形違うやないかい(内海)!!!

栄養素が5角形で足りるわけがないのでした

しかし、ネタ通りに面積はめちゃくちゃ広い!!

可視化のネタにもなる
ミルクボーイのネタでした。

しっかし、ミルクボーイは
プログラミングと相性がいいなーー

まだまだネタが出てきそうで楽しみです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?