Last active
July 10, 2018 09:56
-
-
Save cm-kazup0n/11224b01dd02f107971cc49b3dfa20b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# フォントをインストール\n", | |
"! sudo yum install -y ipa-gothic-fonts" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"## パラメータ\n", | |
"# 体重(kg)\n", | |
"WEGIHT = 80\n", | |
"\n", | |
"# ほろ酔いでいられる時間の量を可視化する。計算方法は下記サイトより\n", | |
"# https://keisan.casio.jp/exec/system/1245312881\n", | |
"\n", | |
"def happy_hours(w, alc, amount):\n", | |
" \"\"\"\n", | |
" ほろ酔いの時間を求める\n", | |
" Args:\n", | |
" w 体重(kg)\n", | |
" alc アルコール度数(パーセント)\n", | |
" amount 飲む量(ミリリットル)\n", | |
" Returns:\n", | |
" ほろ酔いの時間\n", | |
" \"\"\"\n", | |
" return alc/(15*w)*amount - 1000/(15*12) + 1\n", | |
"\n", | |
"# 各アルコールのほろ酔い時間を求めるヘルパー\n", | |
"# ビール 5%\n", | |
"# ワイン 14%\n", | |
"# 酒 15%\n", | |
"\n", | |
"def beer_hours(amount):\n", | |
" return happy_hours(WEGIHT, 5, amount)\n", | |
"\n", | |
"def wine_hours(amount):\n", | |
" return happy_hours(WEGIHT, 14, amount)\n", | |
"\n", | |
"def sake_hours(amount):\n", | |
" return happy_hours(WEGIHT, 15, amount)\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# おまじない\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"import pandas as pd\n", | |
"import matplotlib.font_manager\n", | |
"%pylab inline --no-import-all\n", | |
"\n", | |
"\n", | |
"# フォントの設定\n", | |
"fontprop = matplotlib.font_manager.FontProperties(fname=\"/usr/share/fonts/ipa-gothic/ipag.ttf\")\n", | |
"\n", | |
"plt.style.use('seaborn-whitegrid')\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# 100mlから2000mlまで10ml刻み\n", | |
"idx = np.arange(100, 2000, 10)\n", | |
"\n", | |
"# 各アルコールのほろ酔い時間を求める\n", | |
"df = pd.DataFrame({\n", | |
" 'beer': beer_hours(idx), \n", | |
" 'wine': wine_hours(idx),\n", | |
" 'sake': sake_hours(idx)\n", | |
"}, index=idx)\n", | |
"\n", | |
"\n", | |
"plt.figure(figsize=(10, 8))\n", | |
"plt.title(\"ほろ酔いを楽しむための飲酒量\", fontdict = {\"fontproperties\": fontprop})\n", | |
"plt.xlabel('アルコールの量 (ml)', fontdict = {\"fontproperties\": fontprop})\n", | |
"plt.ylabel('楽しい時間 (時間)', fontdict = {\"fontproperties\": fontprop})\n", | |
"\n", | |
"plt.plot(df['wine'])\n", | |
"plt.plot(df['beer'])\n", | |
"plt.plot(df['sake'])\n", | |
"plt.legend()\n", | |
"\n", | |
"plt.ylim(0, 15)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "conda_python3", | |
"language": "python", | |
"name": "conda_python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment