I was trying to plot GMT grid, but I found the plots between Julia matrix and GMT grid are inconsistent (for clarity, the plot using Julia matrix is the plot I am desire for). So I would like to ask which parameters I should use in xyz2grd
in order to produce the plot I want?
For your ease, here are the codes and plots:
- Julia Matrix
using GMT
using DelimitedFiles
data_file = "./pdf_out.txt"
data = readdlm(data_file)
height, width = size(data)
grdview(data, J="X6i/5i",
xaxis=(annot=:auto, ticks=:auto, label="log10(Period)",),
yaxis=(annot=:auto, ticks=:auto, label="Power [10log10(m**2/sec**4/Hz)] [dB]",),
surftype=:surface, plane=(0, :white),
color=:rainbow, V=true, S=100, Y=4.0,
show=true)
- GMT grid
using GMT
using DelimitedFiles
data_file = "./pdf_out.txt"
data = readdlm(data_file)
height, width = size(data)
data = reshape(data, :) # flatten the array to 1D
data_grid = xyz2grd(data, R="1/$width/1/$height", I="1/1", Z="TLA")
zmin, zmax = extrema(data)
g_cpt = makecpt(color=:rainbow, T="$zmin/$zmax")
grdview(data_grid, J="X6i/5i", color=g_cpt, surftype=:surface, plane=(0, :white),
xaxis=(annot=:auto, ticks=:auto, label="log10(Period)",),
yaxis=(annot=:auto, ticks=:auto, label="Power [10log10(m**2/sec**4/Hz)] [dB]",),
S=100, Y="4.0", show=true)
I also provide the input file (pdf_out.txt
) for reproducing this issue:
pdf_out.txt (136.8 KB)