Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

Hy環境からグラフ描画環境matplotlibを使う

matplotlibはnumpyと合わせて使われる事も多い、
グラフ描画ライブラリです。
qiitaの記事は5000件超、最新で使われてる事例もここ一ヶ月で複数個あるので
使われているライブラリと言っていいでしょう。
今回は、これをHylang経由で使って見ます。

実際のところ

python

"""
=======================================
A simple plot with a custom dashed line
=======================================

A Line object's ``set_dashes`` method allows you to specify dashes with
a series of on/off lengths (in points).
"""
import numpy as np
import matplotlib.pyplot as plt


x = np.linspace(0, 10, 500)
dashes = [10, 5, 100, 5]  # 10 points on, 5 off, 100 on, 5 off

fig, ax = plt.subplots()
line1, = ax.plot(x, np.sin(x), '--', linewidth=2,
                 label='Dashes set retroactively')
line1.set_dashes(dashes)

line2, = ax.plot(x, -1 * np.sin(x), dashes=[30, 5, 10, 5],
                 label='Dashes set proactively')

ax.legend(loc='lower right')
plt.show()

f:id:shuzo_kino:20191128004109p:plain