【问题标题】:Radial animated plots径向动画情节
【发布时间】:2021-01-13 00:44:59
【问题描述】:

我对 Baptiste Coulmont 的 this radial animated visualization(多年来法国每天的死亡人数)感到非常惊讶,我很想自己制作这种情节。

                    

看来作者是用 R 制作的。我想知道这是否可以直接在 gnuplot 中实现,或者是否需要使用通用语言进行编程。

【问题讨论】:

  • 您的输入数据是什么样的?请显示一个数据示例...
  • 它只是一个具有给定周期性的时间序列,因此任何允许指定它的格式都是先验的。对周期性进行硬编码也是一种可能(然后数据只是作为时间序列出现)。

标签: python math plot data-visualization gnuplot


【解决方案1】:

以下内容可以作为 gnuplot 实现的起点。 为了动画检查以下answer。自动量程时似乎存在裁剪极坐标图的问题,即set rrange [0:*],当您设置固定范围时,它似乎不存在,例如set rrange [0:1000]。当然还有调整和改进的空间。

代码:

### 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

结果:

【讨论】:

  • 精彩(这篇文章和链接的),谢谢!
  • 很高兴听到这很有帮助。这对我来说也是一个有趣的挑战。我又学到了一些东西。但请记住,人们投票反对并想结束您的问题,因为他们看不到您的代码和您自己的研究工作。 SO 不是“编码服务”。
  • 请注意,您是对的。挑战 gnuplot 专家确实是我的目标(我认为纯粹在 gnuplot 中是不可行的)。我刚刚在这方面编辑了我的问题。另外,我相信这段代码有一天会对很多人有用,包括我自己,所以再次感谢:)
猜你喜欢
  • 2019-04-25
  • 2014-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-15
  • 2015-04-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多