Skip to content

Instantly share code, notes, and snippets.

reset
set angle radians
#=================== Parameter ====================
a = 4.5 # Coefficient of lituus
k = 15 # 0 ≦ θ ≦ k*pi [rad]
n = 20 # Resolution
N = n * k
#=================== Function ====================
reset
set angle radians
#=================== Parameter ====================
a=0.18 # Coefficient of log spiral
b=0.20
L = 60 # Plot area
k = 10 # 0 ≦ θ ≦ k*pi [rad]
n = 20 # Resolution
cd rounded-pentagram
ffmpeg -framerate 60 -i png/img_%04d.png -vcodec libx264 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -r 60 demo.mp4
ffmpeg -i demo.mp4 -filter_complex "[0:v] fps=30,split [a][b];[a] palettegen [p];[b][p] paletteuse" demo.gif
n = 5
print n # Show n in Terminal
pause(1) # Stop this script for 1 second
# Collatz operations
while (n != 1){
n = (n%2==0) ? (n/2) : (3*n+1)
print n # Show updated n in Terminal
pause(1) # Stop calculation for 1 second
}
#=================== Parameters ====================
rangeN = 1e3 # N = [1:rangeN]
array iterN[rangeN] # Iteration time for input N
array maxN[rangeN] #
array equalN[rangeN] # iterN[i] = iterN[i+1]? -> i/o
# Prepare for data outputting
system sprintf("mkdir N=%.0e", rangeN) # Make the folder
fileName = "data.txt"
filePath = sprintf("N=%.0e/%s", rangeN, fileName)
#=================== Save in folder ====================
folderTerm = 'terminal'
folderPale = 'palette'
system sprintf('mkdir %s %s', folderTerm, folderPale)
#=================== Test in varioius terminal type ====================
set terminal qt 0
test
set terminal qt 1
test palette
@hiroloquy
hiroloquy / lorenz.plt
Last active January 5, 2022 12:18
Strange Attractor (Other examples → https://github.com/hiroloquy/strange-attractor)
set terminal png enhanced font "Times" 20 size 986, 554
set tics font 'Times,18'
set nokey
set grid
set xr[-30:30]
set yr[-30:30]
set zr[0:60]
set xl "x" font"Times:Italic, 22"
set yl "y" font"Times:Italic, 22"
set zl "z" font"Times:Italic, 22"
# Setting ----------------------------------------
reset
set term png size 1280, 720
set margins 0, 0, 0, 0
unset key
unset grid
set xl "x" font"Times:Italic, 22"
set yl "y" font"Times:Italic, 22"
reset
#=================== Setting ====================
set nokey
L = 5.0
set xr[-L:L]
set yr[-L:L]
set xl "{/Times:Italic=18 x}({/Times:Italic=18 t})" font 'Times New Roman, 18'
set yl "{/Times:Italic=18 x}'({/Times:Italic=18 t})" font 'Times New Roman, 18'
set tics font 'Times New Roman,14'
# Loop
if(n%cut==0){
time = sprintf("{/Times:Italic t} = %4.2f",t)
set title time font 'Times,18'
splot u(x, y, t) lc -1
}
t = t + dt # update t
n = n + 1 # update n
if(n <= n_max) reread