8
7

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.

Jupyter Notebookで簡単なグラフを書く

Last updated at Posted at 2019-03-08

Jupyter Notebookで簡単なグラフを書いてみる。

Paiza Cloud

Paiza Cloudを使うと、ブラウザがあればJupyter Notebookが使い始められてお試しにはちょうどいい。無料でも使える。

クラウド開発環境 PaizaCloudクラウドIDE - クラウドIDEでWeb開発!

Paizaのアカウントが無くても、GitHubアカウントでログインできる。

ログインしたら、Jupyter Notebookのコンテナを立ち上げる。

suin___PaizaCloud_-_Instant_Linux_with_Web-UI.png

コンテナが立ち上がるとNotebookのUIが表示されるので、Python3のノートを作る:

Banners_and_Alerts_and_suin___PaizaCloud_-_Instant_Linux_with_Web-UI.png

Paiza Cloud以外では、Homebrewを使ってJupyter Notebookをインストールするのも結構簡単。

Jupyter Notebookにコードを書く

%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

時給 = 2000

def 給与計算(労働時間):
    return 時給 * 労働時間

労働時間 = np.linspace(0, 160, 16)
給与 = 給与計算(労働時間)

fig = plt.figure(dpi=144)
ax = fig.add_subplot(1, 1, 1)
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda 給与, loc: "{:,}".format(int(給与))))
plt.scatter(労働時間, 給与)
plt.plot(労働時間, 給与)
plt.grid(True)
plt.title("労働時間と給与(時給%d円)" % 時給)
plt.xlabel("労働時間")
plt.ylabel("給与")
plt.show()

書いたら「Run」を押すとグラフが描画される。

Untitled.png

便利。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?