Created
September 8, 2021 11:51
-
-
Save Eliran-Turgeman/64b2e341da05da2a41e009e36d7f181c to your computer and use it in GitHub Desktop.
This file contains 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
import sympy | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as ani | |
plt.style.use('dark_background') | |
def convert_to_polar_coordinates(num): | |
return num*np.cos(num), num*np.sin(num) | |
lim = 10000 | |
fig, ax = plt.subplots(figsize = (8, 8)) | |
primes = sympy.primerange(0, lim) | |
primes = np.array(list(primes)) | |
x, y = convert_to_polar_coordinates(primes) | |
def init(): | |
ax.cla() | |
ax.plot([], []) | |
def plot_in_polar(i): | |
ax.cla() | |
ax.plot(x[:i], y[:i], linestyle='', marker='o', markersize=0.75, c='#FFFFFF') | |
ax.set_xlim(-lim, lim) | |
ax.set_ylim(-lim, lim) | |
ax.axis("off") | |
animator = ani.FuncAnimation(fig=fig, func=plot_in_polar, interval=1, frames=len(primes)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment