(请注意,下面的分析可能并不完全正确,我只是粗略地查看了一下来源。)
在创建箭头时,streamplot似乎做了两件事:将箭头面片(类型FancyArrowPatch)添加到轴
向PatchCollection(c.arrows)添加相同的箭头补丁
出于某些原因(我想获得正确的缩放比例是背后的原因),集合似乎没有被使用,也没有添加到轴上。因此,如果更改颜色贴图或集合的颜色,则不会对绘图产生任何影响。在
可能有更漂亮的方法,但是如果你想要,例如,黑色箭头进入你的情节,你可以这样做:import matplotlib.patches
# get the axes (note that you should actually capture this when creating the subplot)
ax = plt.gca()
# iterate through the children of ax
for art in ax.get_children():
# we are only interested in FancyArrowPatches
if not isinstance(art, matplotlib.patches.FancyArrowPatch):
continue
# remove the edge, fill with black
art.set_edgecolor([0, 0, 0, 0])
art.set_facecolor([0, 0, 0, 1])
# make it bigger
art.set_mutation_scale(30)
# move the arrow head to the front
art.set_zorder(10)
这将产生:
然后是通常的警告:这是丑陋和脆弱的。在