2013-04-21 54 views
0

我是matplotlib的新手。我在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') 

會很感激你的幫助。

+0

[如何在matplotlib中自動調整y軸?](http://stackoverflow.com/questions/15375791/how-to-autoscale-y-axis-in-matplotlib) – tacaswell 2013-04-21 22:16:26

+0

http:// stackoverflow。 com/questions/14493334/add-margin-when-plots-run-against-the-edge-of-the-graph?lq = 1 – tacaswell 2013-04-21 22:16:52

+0

http://stackoverflow.com/questions/16003263/matplotlib-modify-autoscaling-規則/ 16003292#16003292 – tacaswell 2013-04-21 22:20:43

回答