4
4

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.

ipython + jupyter + plotly (matplotlib) 設定 & 使い方メモ

Last updated at Posted at 2016-09-21

自分用便利設定たち

Environment & Requirement

  • OS X

  • anaconda3

    • python3
    • ipython
    • matplotlib
    • plotly
    • jupyter

設定

~/.ipython/default_profile 一式を作る。

$ ipython create profile
  • ~/.ipython/profile_default/ipython_config.py
c.InteractiveShellApp.extensions = ['autoreload']
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
  • ~/.ipython/profile_default/ipython_kernel_config.py
c.InteractiveShellApp.matplotlib = 'inline'
  • ~/.ipython/default_profile/startup/00-first.py
import numpy as np
import matplotlib.pyplot as plt
import plotly.offline as py
py.init_notebook_mode()
def plotly(f, *largs, **dargs):
    fig = plt.figure()
    f(*largs, **dargs)
    iplot_mpl(fig)

Sample

x = np.random.randn(10)
y = x+np.random.randn(10)*0.1
plotly(plt.plot,x,y,'bo')

plotlyの使い方をちゃんと覚える気にならなかったのでplotlyでmatplotlibのラッパーを作りたかったが
高階関数使う意外簡単にできる方法思いつかなかった。。。
少しでも複雑なことしようとすれば使えないので
これを見た強い人、他に何かいい方法があれば教えてください。
(plotlyの使い方覚えろというのは正論。。)

plotlyのサンプルにしたがってpyをエイリアスにしたけどそれ使うのは強気すぎる気が。。。w

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?