warnings.filterwarnings('ignore', category=DeprecationWarning, module='.*')
# python用のパッケージ
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
/usr/lib/sagemath/local/lib/python2.7/site-packages/ggplot/utils.py:81: FutureWarning: pandas.tslib is deprecated and will be removed in a future version. You can access Timestamp as pandas.Timestamp pd.tslib.Timestamp, /usr/lib/sagemath/local/lib/python2.7/site-packages/ggplot/stats/smoothers.py:4: FutureWarning: The pandas.lib module is deprecated and will be removed in a future version. These are private functions and can be accessed from pandas._libs.lib instead from pandas.lib import Timestamp /usr/lib/sagemath/local/lib/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead. from pandas.core import datetools /usr/lib/sagemath/local/lib/python2.7/site-packages/traitlets/traitlets.py:770: DeprecationWarning: A parent of InlineBackend._config_changed has adopted the new @observe(change) API clsname, change_or_name), DeprecationWarning)
# 以下のメソッドを呼び出すだけで、手書き風のプロットになる
# plt.xkcd()
# 手書き風を限定したい場合
with plt.xkcd():
x = var('x')
f = x^3 - x^2 - 2*x
f_plt = plot(f, [x, -2.5, 2.5])
show(f_plt, figsize=5)
/usr/lib/sagemath/local/lib/python2.7/site-packages/matplotlib/font_manager.py:1288: UserWarning: findfont: Font family [u'Humor Sans', u'Comic Sans MS'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext]))
x = var('x')
f = x^3 - x^2 - 2*x
f_plt = plot(f, [x, -2.5, 2.5])
show(f_plt, figsize=5)
import seaborn as sns
%matplotlib inline
# 久保本の3章のデータをネットから取り込む# 久保本の3
d = pd.read_csv('http://hosho.ees.hokudai.ac.jp/~kubo/stat/iwanamibook/fig/poisson/data3a.csv')
type(d)
<class 'pandas.core.frame.DataFrame'>
x = var('x')
f = x^3 - x^2 - 2*x
f_plt = plot(f, [x, -2.5, 2.5], figsize=5)
plt.show()
d.hist(column='y', by='f', sharex=True, layout=(2,1), bins=11)
plt.show()