以下代码将通过连接点创建绘图。
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)
plt.show()
如何将绘图更改为竖条而不是连接点?即,更改为以下示例的绘图类型:
感谢。
答案 0 :(得分:2)
使用plt.bar
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.bar(x, y, width=0.08,edgecolor='None',color='k',align='center')
plt.show()