4

I'm making a simulation, which I am trying to display with pyplot. In the simulation, there are circles moving around, and things happen when they overlap. When I try to show this with pyplot, the markers do not appear the right size.

I have tried altering the marker size, but it did not fix the problem. After some testing, I realized that the marker size was independent of the scale of the axes.

This is the code I used for testing

import matplotlib.pyplot as plt
plt.xlim(-1, 1)
plt.ylim(-1, 1)
markersize = 10 # this is here so that it can be changed easily
plt.text (-0.9,-0.9,str(markersize))
plt. scatter([0],[0],[markersize], marker = "o")
plt.show()

The markersize was changed, and the plot was shown

I found out that not only was the size of the marker not related to the scales but when I zoomed in or out, the size of the marker on my screen stayed the same, even if it took more or less on the scale of the axes. To test this out, run the above code with markersize 10000. Put the window on full screen, and depending on your monitor, the marker will probably go from -0.25 to 0.25. Now the same thing, when you make the window smaller, you can get the marker to go from -0.5 to 0.5.

Zoomed out:

img

Zoomed in:

img

I am ultimately looking for a way to make the markersize dependent on the scales of the axes, so in that example, the marker would be from -0.25 to 0.25 no matter how you zoomed in or out. This way, when in the code two circles overlap, they will overlap in the simulation too.

Seanny123
  • 8,776
  • 13
  • 68
  • 124

0 Answers0