matplotlib 自定义标记,空心或实心圆圈内有加号
matplotlib custom marker, empty or filled circle with plus sign inside
我正在尝试使用自定义标记在 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()
我查看了互联网,我认为“\bigoplus”是我要找的东西,但它似乎不起作用。
如果你想使用 '\bigoplus',你应该将它包含在 $...$
中,这会导致字符串由 mathtext(如乳胶)呈现。有关 matplotlib 标记的详细信息,请参阅 here。
如果要增加标记大小,请使用 markersize
。例如,试试这个:
plt.plot(vel, mag, marker='$\bigoplus$', markersize=10, linestyle='None')
我正在尝试使用自定义标记在 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()
我查看了互联网,我认为“\bigoplus”是我要找的东西,但它似乎不起作用。
如果你想使用 '\bigoplus',你应该将它包含在 $...$
中,这会导致字符串由 mathtext(如乳胶)呈现。有关 matplotlib 标记的详细信息,请参阅 here。
如果要增加标记大小,请使用 markersize
。例如,试试这个:
plt.plot(vel, mag, marker='$\bigoplus$', markersize=10, linestyle='None')