我想制作一个带有未填充方块的散点图。markerfacecolor
不是一个被认可的选项scatter https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.scatter.html。我制造了一个MarkerStyle
但散点图似乎忽略了填充样式。有没有办法在散点图中制作未填充的标记?
import matplotlib.markers as markers
import matplotlib.pyplot as plt
import numpy as np
def main():
size = [595, 842] # in pixels
dpi = 72. # dots per inch
figsize = [i / dpi for i in size]
fig = plt.figure(figsize=figsize)
ax = fig.add_axes([0,0,1,1])
x_max = 52
y_max = 90
ax.set_xlim([0, x_max+1])
ax.set_ylim([0, y_max + 1])
x = np.arange(1, x_max+1)
y = [np.arange(1, y_max+1) for i in range(x_max)]
marker = markers.MarkerStyle(marker='s', fillstyle='none')
for temp in zip(*y):
plt.scatter(x, temp, color='green', marker=marker)
plt.show()
main()
看来如果你想使用plt.scatter()
那么你必须使用facecolors = 'none'
而不是设置fillstyle = 'none'
在建设中MarkerStyle
, e.g.
marker = markers.MarkerStyle(marker='s')
for temp in zip(*y):
plt.scatter(x, temp, color='green', marker=marker, facecolors='none')
plt.show()
or, use plt.plot()
with fillstyle = 'none'
and linestyle = 'none'
但自从marker
关键字在plt.plot
不支持MarkerStyle
您必须内联指定样式的对象,即
for temp in zip(*y):
plt.plot(x, temp, color='green', marker='s', fillstyle='none')
plt.show()
其中任何一个都会给你看起来像这样的东西
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)