2015-01-21 33 views
0

我想左對齊圖例的所有元素(原生只有標題左對齊)。 關於如何實現這一點的任何想法?Matplotlib整個傳奇leftaligned

import matplotlib.pyplot as plt, matplotlib _plot = plt.plot(range(5), range(5), label = 'a') legend = plt.legend(loc = 'upper left', title = 'this is a long title')

+0

你能告訴我們一些代碼,再現您所看到的問題? – TheBigH 2015-01-21 10:13:15

+0

'import matplotlib.pyplot as plt,matplotlib _plot = plt.plot(range(5),range(5),label ='a') legend = plt.legend(loc ='left left',title ='這是一個很長的標題')' 以下在中間產生一條線和一條a,而不是在左邊。 – 2015-01-21 14:11:49

+0

@FlavienLambert請編輯您的問題。 – tacaswell 2015-01-22 05:56:18

回答

0

您正在尋找類似的東西? enter image description here

如果這樣你就可以得到它:

x = arange(1.0, 15, 1.0) 
plot(x,log(x),label=r'$y=log(x)$') 
plot(x,5*x,label=r'$y=5x$') 
plot(x,5*x+log(x),label=r'$y=5x+log(x)$') 
plot(x,x**2,label=r'$y=x^2$') 
legend(loc='upper left') 
show()