如何避免线穿过标记物当fillstyle = ‘None’时

huangapple go评论68阅读模式
英文:

How to avoid line crossing the markers when fillstyle = 'None'

问题

我想使用Matplotlib复制下面的图表:

如何避免线穿过标记物当fillstyle = ‘None’时

我尝试了类似于以下的代码:

plt.plot(x, y, color='red', fillstyle='none', marker='*', markersize=10)

问题是线穿过了标记,我想避免这种情况。有什么办法吗?

英文:

I would like to replicate the plot below using Matplotlib:

如何避免线穿过标记物当fillstyle = ‘None’时

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")

如何避免线穿过标记物当fillstyle = ‘None’时

英文:

Just use markerfacecolor="white" instead of 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")

如何避免线穿过标记物当fillstyle = ‘None’时

huangapple
  • 本文由 发表于 2023年5月11日 17:32:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226154.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定