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:
astep
) and radius (rstep
).Further optimization potential:
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: