我不熟悉matplotlib。matplotlib中的图形没有完全显示最后一个标记。我试着增加体型,但没有改变。我需要扩展图形,以便它显示最后一个标记,并将线延伸到标记之外。我的代码是:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1,2,5,10,15,20])
y = np.array([0.049,0.080,0.123,0.166,0.209,0.335])
A = np.vstack([x, np.ones(len(x))]).T
m, c = np.linalg.lstsq(A, y)[0]
x = np.array([0,1,2,5,10,15,20])
y = np.array([c,0.049,0.080,0.123,0.166,0.209,0.335])
plt.plot(x, y, 'r*', label='Original data', markersize=7)
plt.plot(x, m*x + c, 'b', label='Fitted line')
fig = plt.figure(1)
fig.set_size_inches(9,8)
fig.suptitle('THE GRAPH OF ABSORBANCE AGAINST CONCENTRATION',fontsize=20)
plt.xlabel('CONCENTRATION',fontsize=15)
plt.ylabel('ABSORBANCE',fontsize=15)
plt.grid()
fig.savefig('graph.jpg')
在 非常感谢你的帮助。在
(主要从How to autoscale y axis in matplotlib?复制)
你想要
margins
doc前
另请参见Add margin when plots run against the edge of the graph
matplotlib
1.3.x将包含rcParam
值axes.xmargin
和{相关问题 更多 >
编程相关推荐