Skip to content

Instantly share code, notes, and snippets.

@JoshVarty
Created February 1, 2019 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshVarty/e9149c9364d975328a421b5cbb61233d to your computer and use it in GitHub Desktop.
Save JoshVarty/e9149c9364d975328a421b5cbb61233d to your computer and use it in GitHub Desktop.
def generateImagesOfVariousSizes(numberOfPoints):
directory = 'data/countingVariousSizes/' + str(numberOfPoints) + '/'
os.makedirs(directory, exist_ok=True)
#Create 5,000 images of this class
for j in tnrange(5000):
path = directory + str(j) + '.png'
#Get points
x, y = createNonOverlappingPoints(numberOfPoints)
#Create plot
plt.clf()
axes = plt.gca()
axes.set_xlim([-2,2])
axes.set_ylim([-2, 2])
#This time we'll generate a random size for each marker
sizes = [random.uniform(25, 250) for _ in range(len(x))]
plt.scatter(x,y, s=sizes)
plt.axes().set_aspect('equal', 'datalim')
#Save to disk
plt.savefig(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment