2018年4月17日火曜日

開発環境

Pythonからはじめる数学入門 (Amit Saha (著)、黒川 利明 (翻訳)、オライリージャパン)の2章(データをグラフで可視化する)、2.6(プログラミングチャレンジ)、問題2-2(2次関数を視覚的に探索する)を取り組んでみる。

コード(Emacs)

Python 3

#!/usr/bin/env python3

from matplotlib import pyplot as plt

x_values = range(-5, 6)
y_values = [x ** 2 + 2 * x + 1 for x in x_values]

plt.plot(x_values, y_values)
plt.title('x ** 2 + 2 * x + 1')
plt.xlabel('x')
plt.ylabel('y')

plt.savefig('sample2.svg')

入出力結果(Terminal, Jupyter(IPython))

$ ./sample2.py
$

0 コメント:

コメントを投稿