Skip to content

Commit 65132e3

Browse files
authored
Keep the x,y column names of. In special if x contains time. (#1734)
1 parent 2d3b940 commit 65132e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/trend1d.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,20 @@ function trend1d(cmd0::String="", arg1=nothing; kwargs...)
7676
if (opt_F[1] == 'p' || opt_F[1] == 'P' || opt_F[1] == 'c')
7777
colnames = ["a$i" for i=0:size(D,2)-1]
7878
else
79+
cnames = (isa(arg1, GDtype)) ? (isa(arg1, GMTdataset) ? arg1.colnames : arg1[1].colnames) : String[]
7980
s = collect(opt_F)
8081
colnames = Vector{String}(undef, length(s))
8182
for k = 1:numel(s)
82-
if (s[k] == 'x') colnames[k] = "x"
83-
elseif (s[k] == 'y') colnames[k] = "y"
83+
if (s[k] == 'x') colnames[k] = isempty(cnames) ? "x" : cnames[1]
84+
elseif (s[k] == 'y') colnames[k] = isempty(cnames) ? "y" : cnames[2]
8485
elseif (s[k] == 'm') colnames[k] = "model"
8586
elseif (s[k] == 'r') colnames[k] = "residues"
8687
elseif (s[k] == 'w') colnames[k] = "weights"
8788
end
8889
end
8990
end
9091
isa(R, GMTdataset) ? (R.colnames = colnames) : (R[1].colnames = colnames)
92+
(!isempty(cnames) && cnames[1] == "Time") && settimecol!(R, 1) # Set time column
9193
end
9294
return R
9395
end

0 commit comments

Comments
 (0)