简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM