Matplotlib 绘制虚线圆圈(使用 plt.plot 而不是 plt.scatter)
Matplotlib Plot Dashed Circles (using plt.plot instead of plt.scatter)
鉴于以下情况:
import matplotlib.pyplot as plt
import numpy as np
#http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter
x = np.random.randn(60)
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)
plt.plot(x, y, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.plot(x2, y2, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.show()
我希望将 x2 和 y2 绘制为虚线(甚至点线)圆圈。我避免使用 plt.scatter 因为我的脚本的其余部分与 plt.plot 一起工作得更好。
这是我要找的东西:
提前致谢!
仅供参考:
这是我创建的实际图表。我现在只是使用六边形来表示不同的数据(未来数据)。
自定义图例和绘制 pandas 数据框中的行组增加了我无法用 plt.scatter 克服的复杂层。
您可以使用 STIX 字体(带有所有符号的 pdf here) using mathtext functionality
中的虚线圆圈 (ur'$\u25CC$'
)
plt.plot(x, y, marker=ur'$\u25CC$', markerfacecolor='r',
markeredgecolor='r', markersize=30, linestyle='none', )
请注意,markerfacecolor
也设置为一种颜色。
一个缺点是它们需要一定的尺寸才能与闭合圆区分开来。
鉴于以下情况:
import matplotlib.pyplot as plt
import numpy as np
#http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter
x = np.random.randn(60)
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)
plt.plot(x, y, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.plot(x2, y2, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.show()
我希望将 x2 和 y2 绘制为虚线(甚至点线)圆圈。我避免使用 plt.scatter 因为我的脚本的其余部分与 plt.plot 一起工作得更好。
这是我要找的东西:
提前致谢!
仅供参考: 这是我创建的实际图表。我现在只是使用六边形来表示不同的数据(未来数据)。
自定义图例和绘制 pandas 数据框中的行组增加了我无法用 plt.scatter 克服的复杂层。
您可以使用 STIX 字体(带有所有符号的 pdf here) using mathtext functionality
中的虚线圆圈 (ur'$\u25CC$'
)
plt.plot(x, y, marker=ur'$\u25CC$', markerfacecolor='r',
markeredgecolor='r', markersize=30, linestyle='none', )
请注意,markerfacecolor
也设置为一种颜色。
一个缺点是它们需要一定的尺寸才能与闭合圆区分开来。