@@ -444,9 +444,9 @@ function _best_label_pos(D::Vector{<:GMTdataset}, labels::Vector{String}, nc::In
444444 end
445445
446446 # Text half-dimensions in cm
447- pt2cm = 2.54 / 72
448- char_w = 0.55 * fontsize * pt2cm
449- char_h = fontsize * pt2cm
447+ fs = fontsize * 2.54 / 72
448+ char_w = 0.55 * fs
449+ char_h = fs
450450 hws = [length (l) * char_w / 2 for l in labels] # half-width per label
451451 hh = char_h * 0.9 # half-height (shared)
452452
@@ -820,7 +820,7 @@ Called from `_common_plot_xyz()` when the `labellines` keyword is used.
820820- `val` can be a `Vector{<:AbstractString}` with one label per curve, or a NamedTuple with fields
821821 `labels` (required), `fontsize` (default 8), and `prefer` (`:begin`, `:middle`, or `:end`; default `:middle`).
822822"""
823- function add_labellines! (curves, d:: Dict{Symbol,Any} , _cmd:: Vector{String} )
823+ function add_labellines! (curves, d:: Dict{Symbol,Any} , _cmd:: Vector{String} ):: Nothing
824824 val = find_in_dict (d, [:labellines ])[1 ]
825825 if isa (val, Vector{<: AbstractString })
826826 labels = [string (l) for l in val]
@@ -835,7 +835,7 @@ function add_labellines!(curves, d::Dict{Symbol,Any}, _cmd::Vector{String})
835835 else
836836 _add_labellines (curves, _cmd, labels, 8 , :middle )
837837 end
838- return curves
838+ return nothing
839839 end
840840 # NamedTuple path — dispatch to the right inner function based on which options are set
841841 dd = nt2dict (val)
@@ -845,7 +845,7 @@ function add_labellines!(curves, d::Dict{Symbol,Any}, _cmd::Vector{String})
845845 if get (dd, :outside , false ) == true
846846 text_cmd = _inject_outside_labels! (d, curves, labels, fnt, _cmd)
847847 push! (_cmd, text_cmd)
848- return curves
848+ return nothing
849849 end
850850 xv = get (dd, :xvals , nothing )
851851 yv = get (dd, :yvals , nothing )
@@ -855,10 +855,10 @@ function add_labellines!(curves, d::Dict{Symbol,Any}, _cmd::Vector{String})
855855 _yv:: Vector{Float64} = yv === nothing ? Float64[] : isa (yv, Real) ? fill (Float64 (yv), nc) : Float64 .(yv)
856856 pos = _label_pos_at_vals (curves, nc, _xv, _yv)
857857 _add_labellines_apply (curves, _cmd, labels, fnt, pos)
858- return curves
858+ return nothing
859859 end
860860 _add_labellines (curves, _cmd, labels, fnt, prefer)
861- return curves
861+ return nothing
862862end
863863
864864function _add_labellines (arg1:: Vector{<:GMTdataset} , _cmd:: Vector{String} , labels:: Vector{String} , fontsize:: Int , prefer:: Symbol )
@@ -908,11 +908,7 @@ function _outside_label_data(D::Vector{<:GMTdataset}, labels::Vector{String}, fo
908908 (ymax - ymin) < 1e-10 && (ymin -= 0.5 ; ymax += 0.5 ) # degenerate range fallback
909909
910910 # x positions: at the right edge of the plot region so labels start just beyond the axis
911- if CTRL. limits[7 ] != 0
912- xmax = CTRL. limits[8 ]
913- else
914- _, xmax, _, _ = getregion (D)
915- end
911+ xmax = (CTRL. limits[7 ] != 0 ) ? CTRL. limits[8 ] : getregion (D)[2 ]
916912 xs = Vector {Float64} (undef, nc)
917913 ys = Vector {Float64} (undef, nc)
918914 colors = Vector {String} (undef, nc)
@@ -925,8 +921,7 @@ function _outside_label_data(D::Vector{<:GMTdataset}, labels::Vector{String}, fo
925921 # Repel overlapping labels vertically
926922 pw, ph = _get_plotsize ()
927923 sy = ph / (ymax - ymin)
928- pt2cm = 2.54 / 72
929- label_h = fontsize * pt2cm * 1.4 # label height in cm with some padding
924+ label_h = fontsize * 2.54 / 72 * 1.4 # label height in cm with some padding
930925 min_sep = label_h / sy # minimum separation in data units
931926
932927 order = sortperm (ys)
@@ -1012,9 +1007,9 @@ function text_repel(points, labels::Vector{<:AbstractString}; fontsize::Int=10,
10121007 ay = (py .- ymin) .* sy
10131008
10141009 # Text box half-dimensions in cm (with padding)
1015- pt2cm = 2.54 / 72
1016- char_w = 0.55 * fontsize * pt2cm
1017- char_h = fontsize * pt2cm
1010+ fs = fontsize * 2.54 / 72
1011+ char_w = 0.55 * fs
1012+ char_h = fs
10181013 pad = Float64 (padding)
10191014 hws = [length (l) * char_w / 2 + pad for l in labels]
10201015 hhs = fill (char_h / 2 + pad, n)
0 commit comments