我在Python(3.4)Jupyter Notebook中有以下代码来绘制直方图:
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
bins = np.linspace(0, 1.0, 40)
plt.hist(list1, bins, alpha = 0.5, color = 'b')
plt.show()
我想知道我可以重新调整它以使y轴值的最大值为100吗?谢谢!
答案 0 :(得分:0)
这是一个MWE:
import matplotlib.pyplot as plt
import numpy as np
bins = np.linspace(0, 1.0, 40)
y = np.random.rand(100)
plt.hist(y, bins)
plt.ylim((None, 100)) # This line sets the y-axis limits
plt.show()