Radial animated plots

I am quite amazed by this radial animated visualization (of daily number of deaths in France over years) by Baptiste Coulmont, and I would love to make my own plots of this kind.

                    radial animated plot (screenshot)

It seems the author produced it with R. I wonder if this is feasible directly within gnuplot, or if it requires programming in a general-purpose language.

Answer

The following could serve as starting point for a gnuplot implementation. In order to animate check the following answer. There seems to an issues of clipping the polar graph when autoranging, i.e. set rrange [0:*], which doesn’t seem to be present when you set a fixed range, e.g. set rrange [0:1000]. There is certainly room for adaptions and improvements.

Code:

### radial animated plot
reset session

# create some random test data
# Gauss curve by specifing Amplitude A, position x0 and width via FWHM
GaussW(x,x0,A,FWHM) = A * exp(-(x-x0)**2/(2*(FWHM/(2*sqrt(2*log(2))))**2))
myTimeFmt = "%d.%m.%Y"
StartDate = "01.01.2018"
EndDate   = "31.12.2020"
t0=int(strptime(myTimeFmt,StartDate))
t1=int(strptime(myTimeFmt,EndDate))
SecPerDay = 3600*24
set print $Data
    do for [t=t0:t1:SecPerDay] {
        Date = strftime(myTimeFmt,t)
        y0 = rand(0)*200+400
        y1(t) = GaussW(t,strptime(myTimeFmt,"01.02.2020"),100,SecPerDay*30)
        y2(t) = GaussW(t,strptime(myTimeFmt,"01.04.2020"),300,SecPerDay*10)
        y3(t) = GaussW(t,strptime(myTimeFmt,"10.10.2020"),400,SecPerDay*30)
        print sprintf("%s %g",Date,y0+y1(t)+y2(t)+y3(t))
    }
set print

DaysInMonth(t) = int(strftime("%d",strptime("%m.%Y",sprintf("%02d.%04d",tm_mon(t)+2,tm_year(t)))-1))
DateToAngle(t) = tm_mday(t)/DaysInMonth(t)*30 + tm_mon(t)*30
MonthToAngle(m) = (m-1)*30    # m=1 to 12

myDate(col) = DateToAngle(strptime(myTimeFmt,strcol(col)))
myColor(col) = tm_year(strptime(myTimeFmt,strcol(col)))

# extract the available years from data into table
set table $Legend
    unset polar
    plot $Data u (tm_year(strptime(myTimeFmt,strcol(1)))):(1) smooth freq
    set polar
unset table

set size ratio -1
set polar
set theta clockwise top
set angle degrees
set grid
set border 0 polar
unset raxis
unset xtics
set ttics 30
set format r ""
set rtics scale 0,0

# month labels
myMonth(i) = strftime("%b",i*SecPerDay*28)
do for [i=1:12] {
    set ttics add (myMonth(i) MonthToAngle(i))
}

set key at screen 0.95, screen 0.95 right
set rrange[0:1000]
set ytics 0,200 scale 0,0 nomirror offset -4,0
set rtics 200

plot $Data u (myDate(1)):2:(myColor(1)) w l lc var notitle, 
     for [i=5:|$Legend|-2] $Legend u (NaN):(NaN):1 every ::i-5::i-5 
        w l lw 2 lc var ti sprintf("%s", word($Legend[i],1))
### end of code

Result:

enter image description here