英文:
How to avoid line crossing the markers when fillstyle = 'None'
问题
我想使用Matplotlib复制下面的图表:
我尝试了类似于以下的代码:
plt.plot(x, y, color='red', fillstyle='none', marker='*', markersize=10)
问题是线穿过了标记,我想避免这种情况。有什么办法吗?
英文:
I would like to replicate the plot below using Matplotlib:
I tried with something like:
plt.plot(x, y, color=‘red’, fillstyle=‘none’, marker=“*”, markersize=10)
The problem is that the line crosses the markers, and I would like to avoid this. Any idea on how to do that?
答案1
得分: 0
只需使用 markerfacecolor="white"
而不是 fillstyle="none"
:
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [1, 2, 4]
plt.plot(x, y, color="red", marker="*", markersize=10, markerfacecolor="white")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论