- Bir ileterek birden yatay çizgiler çizmek Can
listiçin yparametre.
y tek bir konum olarak geçilebilir: y=40
y birden çok konum olarak geçilebilir: y=[39, 40, 41]
- Bir böyle bir şey ile bir rakam komplo ediyorsanız
fig, ax = plt.subplots(), o zaman değiştirin plt.hlinesveya plt.axhlinebirlikte ax.hlinesveya ax.axhlinesırasıyla.
matplotlib.pyplot.axhlineyalnızca tek bir konumu çizebilir (örneğin y=40)
plt.plot
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(6, 3))
plt.hlines(y=39.5, xmin=0, xmax=len(xs), colors='aqua', linestyles='--', lw=2, label='Single Line')
plt.hlines(y=[39, 40, 41], xmin=0, xmax=len(xs), colors='purple', linestyles='--', lw=2, label='Multiple Lines')
plt.legend(bbox_to_anchor=(1.04,0.5), loc="center left", borderaxespad=0)

ax.plot
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(1, 21, 200)
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6, 6))
ax1.hlines(y=40, xmin=0, xmax=len(xs), colors='r', linestyles='--', lw=2)
ax1.set_title('One Line')
ax2.hlines(y=[39, 40, 41], xmin=0, xmax=len(xs), colors='purple', linestyles='--', lw=2)
ax2.set_title('Multiple Lines')
plt.show()
