Matplotlib Plot Dashed Circles

天大地大妈咪最大 提交于 2019-12-13 07:30:52

问题


Given the following:

import matplotlib.pyplot as plt 
import numpy as np 

x = np.random.randn(60) 
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)

plt.scatter(x, y, s=80, facecolors='none', edgecolors='r')
plt.scatter(x2, y2, s=80, facecolors='none', edgecolors='r')
plt.show()

How would I plot this same data with dashed circles instead (where the outline of each circle is dashed instead of solid) for x 2 and y2 only?

Thanks in advance!

Update: I know this can be done with patches as in here, but I need it to be done via plt.scatter if possible because I will also be plotting another set of circles on the same plot and using patches messed with the chart dimensions (was way too thin).


回答1:


Pass linestyle='--' to scatter.

plt.scatter(x, y, s=80, facecolors='none', edgecolors='r')
plt.scatter(x2, y2, s=80, facecolors='none', edgecolors='r',
            linestyle='--')

For that marker size I would rather use linestyle=':' though.



来源:https://stackoverflow.com/questions/41106312/matplotlib-plot-dashed-circles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!