matplotlibgoogle-maps-markers

Matplotlib Plot Dashed Circles


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 x2 and y2 only?

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


Solution

  • 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='--')
    

    enter image description here

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