2017-03-05 161 views
0

我想在自定義標記matplotlib做一個簡單的情節。我正在尋找一個標記,看起來像一個空的或實心的圓圈,加號從內向外延伸enter image description here。另外我想設置一個自定義(大於默認值)的標記大小。這個標記是呈現數據所必需的。我在這裏附上我的代碼:matplotlib自定義標記,空或用內部加號實心圓

import sys 
import os 
import numpy 
import matplotlib.pyplot as plt 
from pylab import * 


trap_error = 'mag_velocity.txt' 

mag, vel = numpy.loadtxt(trap_error, unpack =True) 

#plt.plot(vel, mag, '\\bigoplus') 
plt.plot(vel, mag, marker='$\\bigoplus$', markersize=15)  
plt.ylim(-11, -19) 
plt.xlim(-2, -7) 

plt.show() 

enter image description here

我看着互聯網,我想「\ bigoplus」是什麼,我在尋找,但似乎沒有工作。

回答

1

如果您想使用'\ bigoplus',您應該將其包含在$...$中,這會導致字符串由mathtext(如latex)呈現。有關matplotlib標記的詳細信息,請參見here

如果要增加標記大小,請使用markersize。例如,試試這個:

plt.plot(vel, mag, marker='$\\bigoplus$', markersize=10, linestyle='None') 
+0

感謝@Douglas,如果我這樣做,我的劇情使得線圖,而不是分散的標記,請參見下面的更新後的圖像。 plt.scatter返回給我一些錯誤,你能告訴我如何使它成爲唯一的陰謀嗎? – bhjghjh

+0

好點,加'linestyle ='None'去除線條。我也更新了答案。 –