2018-01-22から1日間の記事一覧

matplotlib / pyplot, lines / 単振り子を描く Polygon(), Circle(), Line2D()

from matplotlib import pyplot as plt from math import sin, cos, pi def createPend(length, radian): x = length * sin(radian) y = length * cos(radian) line = plt.Polygon(((0,0), (x,y)), closed=False, color="black") circle = plt.Circle((x,y),…

matplotlib / pyplot / 一定時間ごとに何かを動かす FuncAnimation()

参考: Pythonからはじめる数学入門, p.163-165 from matplotlib import pyplot as plt from matplotlib import animation from math import sin def createCircle(): return plt.Circle((0,0), 1) def movePos(i, circle): # i はフレーム番号。 circle.cent…

matplotlib / pyplot / 一定時間ごとに何かをする FuncAnimation()

from matplotlib import pyplot as plt from matplotlib import animation def frameNum(i): # i はフレーム番号 print(i) fig = plt.gcf() # FuncAnimation オブジェクトは、何かの変数に代入しておかないとガーベジコレクションされてしまう。 sute = anim…