Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 plt.show() it opens 25 window (25 is length of x). Any ideas?

like image 540
ashim Avatar asked May 04 '12 21:05

ashim


1 Answers

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')
plt.show()
like image 84
Maehler Avatar answered Oct 07 '22 03:10

Maehler