Skip to content

Commit 0d27abd

Browse files
authored
SEveral improvements to the plotyy function. (#1882)
1 parent 607035c commit 0d27abd

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/plot.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,12 @@ function plotyy(arg1, arg2; first=true, kw...)
158158
d = KW(kw)
159159
(haskey(d, :xlabel)) ? (xlabel = string(d[:xlabel])::String; delete!(d, :xlabel)) : xlabel = "" # Only to used at the end
160160
(haskey(d, :seclabel)) ? (seclabel = string(d[:seclabel])::String; delete!(d, :seclabel)) : seclabel = ""
161-
fmt = ((val = find_in_dict(d, [:fmt])[1]) !== nothing) ? arg2str(val)::String : FMT[]::String
161+
fmt::String = ((val = find_in_dict(d, [:fmt])[1]) !== nothing) ? arg2str(val)::String : FMT[]::String
162162
savefig = ((val = find_in_dict(d, [:savefig :figname :name])[1]) !== nothing) ? arg2str(val)::String : nothing
163163
Vd = ((val = find_in_dict(d, [:Vd])[1]) !== nothing) ? val : 0
164164

165-
cmd::String, opt_B::String = parse_B(d, "", " -Baf -BW")
165+
xaxis = find_in_dict(d, [:xaxis])[1]; xaxis2 = find_in_dict(d, [:xaxis2])[1] # These are only for -Bx
166+
opt_B::String = parse_B(d, "", " -Baf -BW")[1] # This would not ignore :xaxis and :xaxis2 but that would screw WE axes
166167
if (opt_B != " -Baf -BW")
167168
if (occursin(" -Bx", opt_B) || occursin(" -By", opt_B) || occursin("+t", opt_B))
168169
# OK, so here's the problem. Both title and label maybe multi-words, case in which they will have the
@@ -183,9 +184,12 @@ function plotyy(arg1, arg2; first=true, kw...)
183184
else
184185
d[:B] = " af W"
185186
end
187+
186188
(Vd != 0) && (d[:Vd] = Vd)
189+
lw = get(d, :lw, nothing)
187190
d[:lc] = "#0072BD"
188191
do_show = ((val = find_in_dict(d, [:show])[1]) !== nothing && val != 0)
192+
in_conf = get(d, :conf, nothing) # If there is a incomming one, save it to apply also to the xaxis (Date/time axis do that)
189193
d[:par] = (MAP_FRAME_PEN="#0072BD", MAP_TICK_PEN="#0072BD", FONT_ANNOT_PRIMARY="#0072BD", FONT_LABEL="#0072BD")
190194
r1 = common_plot_xyz("", cat_1_arg(arg1, true), "plotyy", first, false, d)
191195

@@ -195,11 +199,16 @@ function plotyy(arg1, arg2; first=true, kw...)
195199
d[:B] = " af E" * seclabel # Also remember that previous -B was consumed in first call
196200
d[:lc] = "#D95319"
197201
d[:par] = (MAP_FRAME_PEN="#D95319", MAP_TICK_PEN="#D95319", FONT_ANNOT_PRIMARY="#D95319", FONT_LABEL="#D95319")
202+
(lw !== nothing) && (d[:lw] = lw)
198203
r2 = common_plot_xyz("", cat_1_arg(arg2, true), "plotyy", false, false, d)
199204

200205
(xlabel != "" && occursin(" ", xlabel)) && (xlabel = "\"" * xlabel * "\"")
201206
opt_B = (xlabel != "") ? "af Sn x+l" * xlabel : "af Sn"
202-
r3 = basemap!(J="", R="", B=opt_B, Vd=Vd, fmt=fmt, name=savefig, show=do_show)
207+
(xaxis !== nothing) && (dd = Dict{Symbol,Any}(:xaxis => xaxis); opt_B = parse_B(dd, opt_B, "")[1])
208+
(xaxis2 !== nothing) && (dd = Dict{Symbol,Any}(:xaxis2 => xaxis2); opt_B = parse_B(dd, opt_B, "")[1])
209+
opt_f = isa(arg1, GMTdataset) ? set_fT(arg1, "", "") : "" # See if Timecol is present and set -f0T if yes
210+
_f = (opt_f !== "") ? opt_f[4:end] : ""
211+
r3 = basemap!(J="", B=opt_B, conf=in_conf, f=_f, Vd=Vd, fmt=fmt, name=savefig, show=do_show)
203212
return (Vd == 2) ? [r1;r2;r3] : nothing
204213
end
205214
# ------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)