0

the past days I tried to plot a matrix into a polar 2D heatmap. The matrix consists of 80x720 data points. To specify the whole thing a bit more. It is data from a XRD in polar coordinates (a pole figure). The columns are the angular the sample was rotated around between 0° and 360° in steps of 0.5° (lets call it phi), the rows are another angular the sample was tilted by between 35° and 75° in 0.5° steps (lets call this one psi). The value on a specific position in the matrix is the intensity from the detector at these angulars. I want to end up with a polar plot where the radius is psi, the angular is phi and z or more precise the color represents the intensity.

I already found this nicely discussed question but could not apply it to my problem. I managed to plot the whole thing with splot -file- matrix u ($2/2):($1/2):3 using a pm3d map but thats obviously not polar.

Does anyone here has an idea how to plot the matrix in polar form? Thanks very much! Any advice about what direction to take would be very much appreciated

(I also have 80 individual data files of this measurement with the psi angular (0°-360°) and the corresponding intensity which didn't help me much so far).

cheers Flo

  • 1
    I'm not aware of a direct gnuplot polar heatmap plotting style, but you could check this as a starting point... https://stackoverflow.com/a/62447578/7295599 This needs to be adapted to your specific problem. – theozh Sep 06 '21 at 17:27

1 Answers1

0

Please see help set mapping for an explanation of the coordinate transform produced by set mapping cylindrical. If I understand correctly, you may be able to use something like:

set mapping cylindrical
set view equal xy
set view map
set angle degrees
splot 'data' matrix using 2:1:3 with pm3d

If the numerical values in the file are not already angular values, you may need conversion functions, e.g. from sample number to the corresponding angle:

theta(col) = col * 0.5
phi(row) = some_offset + row * some_scale_factor
splot 'data' matrix using (theta($2)) : (phi($1)) : 3 with pm3d

If that comes out badly, please attach an actual data file so that we can sort out what additional data specification might be necessary. I show below an example using artificial data in the form of a linear gradient. The urange and vrange are only relevant to define the sampling grid for the artificial data '++' ; you don't need them for data from a file.

set cblabel "Intensity"
unset border
set tics nomirror
set xtics axis; set ytics axis
set xzeroaxis; set yzeroaxis
set vrange [25:290]    # This is the column number (theta in 0.5° steps)
set urange [10:20]     # This is the row number (phi)

splot '++' using (theta($2)) : 1 : ($1) with pm3d notitle

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • Amazing! It is working now. I have used the mapping command before but it did not work. I played around with it a while and permutated the argument in "splot using" a bit and now it is working. I don't know why but I had to change it to 2:3:1 now. Thank you so much! I was going crazy with this plot. – oFlo Sep 07 '21 at 09:07
  • Is there by any chance an easy way of aligning the splot with the polar "empty" plot without shifting and scaling a lot? – oFlo Sep 07 '21 at 09:13
  • No, but you could use `set xtics axis; set ytics axis; set xzeroaxis; set yzeroaxis` to reposition the x and y labels to the center of the plot. – Ethan Sep 07 '21 at 16:38