1

Given the following:

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

I'd like for x2 and y2 to be plotted as dashed (or even dotted) circles. I am avoiding the use of plt.scatter because the rest of my script works with plt.plot much better. Here's what I'm looking for: enter image description here

Thanks in advance!

FYI: Here's the actual chart I created. I just used hexagons for now to signify the different data (future data).

enter image description here

The custom legend and plotting over groups of rows in a pandas Data Frame add layers of complexity that I couldn't overcome with plt.scatter.

3
  • 1
    For that you would have to pass a Path instance as marker. I did not find a way to make a dashed circle. Maybe it is not possible, scatter uses additional properties of PathCollection for the marker edges. I would say that if you want to plot so many circles that performance is an issue then dashed edges are not the best way to tell some of them apart. Color, sizes or shapes will work much better. Commented Dec 12, 2016 at 21:12
  • Can you comment why using scatter is such a big problem? Commented Dec 12, 2016 at 21:16
  • Sure. I am iterating through a list to plot points from various rows of a data frame. Each row's data is colored based on a list of colors (though this will soon change to a color map). Then I create a custom legend. There are a lot of dependencies and I'm not sure they will work with plt.scatter. See updated question for my example. Commented Dec 12, 2016 at 21:25

1 Answer 1

8

You can use the dotted circle (ur'$\u25CC$') from the STIX font (pdf with all symbols here) using mathtext functionality

 plt.plot(x, y, marker=ur'$\u25CC$', markerfacecolor='r', 
                markeredgecolor='r', markersize=30, linestyle='none', )

Note, that markerfacecolor is set to a color as well.

A drawback is that they need a certain size to be distinguishable from a closed circle.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.