Gnuplot极坐标图直方图 [英] Gnuplot Polar Coodinates Histogram

查看:132
本文介绍了Gnuplot极坐标图直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据文件 file.dat ,其中包含平面中各点的三列(半径,角度,温度),我想使用极性坐标和色图将数据绘制为直方图,如下图所示,但使用gnuplot.我可以使用所需的垃圾箱值创建一个 histogram.dat 文件,但我不知道如何在gnuplot中绘制该文件

解决方案

据我所知,gnuplot中没有立即使用的极性热图"绘图样式(但我可能是错的,至少,我没有看到演示页上的示例).因此,您必须自己实施.

基本上,必须为每个数据点绘制一个填充的线段.因此,对于每个数据点,您都必须在该单个线段的圆周上创建点.然后,您可以使用填充曲线和特定颜色来绘制此段.

假设:

  • 数据位于规则的网格/角度( astep )和半径( rstep )的阶梯中.
  • 数据位于数据块中(如何将其从文件获取到数据块中,请参见

    I have a data file file.dat with three columns (radio, angle, Temperature) for points in the plane, and I want to plot this data as a histogram using polar coordenates and color maps, like in the figure below but using gnuplot. I can create a histogram.dat file with the values of the bins that I want but I don't know how to plot it in gnuplot

    解决方案

    To my knowledge there is no right-away "polar heatmap" plotting style in gnuplot (but I could be wrong, at least, I haven't seen an example on the demo page). Hence, you have to implement it yourself.

    Basically, for each datapoint you have to plot a filled segment. Therefore, for each datapoint you have to create points on the circumference of this single segment. Then you can plot this segment with filledcurves and a specific color.

    Assumptions:

    • data is in a regular grid/steps in angle (astep) and radius (rstep).
    • data is in a datablock (how to get it from a file into a datablock, see gnuplot: load datafile 1:1 into datablock)
    • separators are whitespaces
    • no header lines

    Further optimization potential:

    • automatic extraction of astep and rstep.

    I hope you can adapt the code to your needs.

    Code:

    ### workaround for polar heatmap
    reset session
    
    set size square
    set angle degrees
    unset border
    unset tics
    set cbtics
    set polar
    set border polar
    unset raxis
    
    # create some test data
    f(a,r) = r*cos(a) * r*sin(a) + rand(0)*100
    set print $Data
        do for [a=0:350:10] {
            do for [r=1:20] {
                print sprintf("%g %g %g",a,r,f(a,r))
            }
        }
    set print
    
    astep = 10
    rstep = 1
    
    # create the segments for each datapoint
    set print $PolarHeatmap
        do for [i=1:|$Data|] {
            a = real(word($Data[i],1))
            r = real(word($Data[i],2))
            c = real(word($Data[i],3))
            do for [j=-5:5] {
                print sprintf("%g %g %g",a+j*astep/10., r-0.5*rstep, c)
            }
            do for [j=5:-5:-1] {
                print sprintf("%g %g %g",a+j*astep/10., r+0.5*rstep, c)
            }
            print ""
            print ""
        }
    set print
    
    set style fill noborder
    set palette defined (0 "blue", 1 "grey", 2 "green")
    
    plot $PolarHeatmap u 1:2:3 w filledcurves palette notitle
    ### end of code
    

    Result:

    这篇关于Gnuplot极坐标图直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆