matplotlib, can plot but not scatter


I have weird behaviour of matplotlib.pyplot. I have two array x and y. I want scatter these point. so I use scatter function:

ax.scatter(x, y, 'r')
plt.xlabel('average revsion size')
plt.ylabel('time (seconds)')
plt.savefig('time.png', format='png')

this piece of code give me error otImplementedError: Not implemented for this type But if I substitute plt.scatter by plt.plot, then it plots it. What is the problem could be.

Also If I use it opens 25 window (25 is length of x). Any ideas?

5/4/2012 9:02:24 PM

Accepted Answer

The thing is that scatter and plot don't take the arguments in the same order. Try using scatter(x, y, c='r') instead (assuming it was the coloring you intended to set). Take a look at the documentation for scatter as well.

from matplotlib import pyplot as plt

x = [1,2,3,4,5,6]
y = [2,4,6,3,1,5]

plt.scatter(x, y, c='r')
5/4/2012 9:27:38 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow