在运行以下程序时,有一句代码:use_line_collection=True不明白用法。
from scipy.stats import binom
import matplotlib.pyplot as plt
import numpy as np
n,p=5,0.4
x=np.arange(6)
y=binom.pmf(x,n,p)
plt.subplot(1,2,1)
plt.plot(x,y,'ro')
plt.vlines(x,0,y,'k',lw=3,alpha=0.5)
plt.subplot(1,2,2)
plt.stem(x,y,use_line_collection=True)
plt.show()
上网查了一下,感觉最贴切的是这个说法:
When using the keyword use_line_collection=True
(default behavior since Matplotlib 3.3) one can update the three elements
- markerline
- stemlines
- baseline
先复制过来放到这里,希望后面随着理解的深入能弄懂。
原文出处: