linestyleには4種類の線を指定することができます。
使用するには、linestyle引数に線の種類を与えてください。
種類 | 指定方法 | 見た目 |
実線 | ‘solid’ or ‘-‘ | ![]() |
点線 | ‘dotted’ or ‘:’ | ![]() |
破線 | ‘dashed’ or ![]() | ![]() |
一点鎖線 | ‘dashdot’ or ‘-.’ | ![]() |
例
import matplotlib.pyplot as plt
import numpy as np
plt.hlines(1, -5, 5, linestyle='solid')
plt.hlines(2, -5, 5, linestyle='dotted')
plt.hlines(3, -5, 5, linestyle='dashed')
plt.hlines(4, -5, 5, linestyle='dashdot')
plt.show()

自分でlinestyleをカスタマイズする方法はこちらからどうぞ
コメント