Created
February 1, 2019 20:24
-
-
Save JoshVarty/e9149c9364d975328a421b5cbb61233d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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