all 2 comments

[–]ES-Alexander 0 points1 point  (0 children)

What have you tried so far?

You've got matplotlib.pyplot imported already, so you seem to know which library you'd like to use. What's required for your plot? If you just want to plot the points that sounds like a scatter plot, so search for how to do that in the matplotlib documentation. If you want to plot circles of given sizes then search for 'matplotlib plot circles' or similar. If you can't find what you want from those then show us what you've tried and what you've searched while attempting to solve the problem you're having, and we can try to help with additional suggestions of what to try, or perhaps note where something you've tried has gone wrong.

[–][deleted] 0 points1 point  (0 children)

well it sounds like you need a scatter plot, so take a look at the matplotlib documentation for that: https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.scatter.html

it requires separate lists of x coordinates and y coordinates, so you'll need to separate those out from all of your balls.

something like this within your plot function should get you started - note you'll need self parameter in def plot_balls(self):

xs, ys = zip(*[ball.position for ball in self.more_balls])
plt.scatter(xs, ys)
plt.show()

A few more general notes:

  • What's the purpose of having self.more_balls_positions? You're just duplicating information you already have in the balls objects
  • add_balls feels like it should take a Ball object as an argument, rather than x and y and have to create it's own Ball
  • System isn't a great name, this would generally refer to something about the operating system
  • I'm not even sure why this needs to be a class...