Skip to content

Instantly share code, notes, and snippets.

@Wikunia
Created October 8, 2019 21:12
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 Wikunia/9124430d3d7f9596c0b5cbd7a694fd73 to your computer and use it in GitHub Desktop.
Save Wikunia/9124430d3d7f9596c0b5cbd7a694fd73 to your computer and use it in GitHub Desktop.
Plot polar prime animation
using Plots
using ColorSchemes
using Primes
using Plots.PlotMeasures
function plot_primes(x)
l_primes = primes(x)
colors = get(ColorSchemes.summer, [i/x for i in l_primes])
anim = Animation("temp", String[])
for i=1:100
scatter(l_primes[1:i], l_primes[1:i]; size=(1000,1000), legend=false, axis=false, background_color=:black, foreground_color=:black,
proj=:polar, markersize=1, markercolor=colors, left_margin=0mm, bottom_margin=0mm, top_margin=0mm, right_margin=0mm, aspect_ratio=:equal)
frame(anim)
end
for i=101:2:300
scatter(l_primes[1:i], l_primes[1:i]; size=(1000,1000), legend=false, axis=false, background_color=:black, foreground_color=:black,
proj=:polar, markersize=1, markercolor=colors, left_margin=0mm, bottom_margin=0mm, top_margin=0mm, right_margin=0mm, aspect_ratio=:equal)
frame(anim)
end
for i=301:5:800
scatter(l_primes[1:i], l_primes[1:i]; size=(1000,1000), legend=false, axis=false, background_color=:black, foreground_color=:black,
proj=:polar, markersize=1, markercolor=colors, left_margin=0mm, bottom_margin=0mm, top_margin=0mm, right_margin=0mm, aspect_ratio=:equal)
frame(anim)
end
for i=801:25:length(l_primes)
scatter(l_primes[1:i], l_primes[1:i]; size=(1000,1000), legend=false, axis=false, background_color=:black, foreground_color=:black,
proj=:polar, markersize=1, markercolor=colors, left_margin=0mm, bottom_margin=0mm, top_margin=0mm, right_margin=0mm, aspect_ratio=:equal)
frame(anim)
end
run(`ffmpeg -framerate 30 -i "temp/%06d.png" -vcodec libx264 -crf 25 polar_primes_$(x).mp4`)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment