Better legend anchor algorithm

This commit is contained in:
David Gustavsson 2021-03-02 08:01:59 +01:00
parent 6724a3a2fe
commit 1d3e0a5d5d
2 changed files with 4 additions and 2 deletions

View File

@ -384,7 +384,7 @@ end
plotly_legend_pos(v::Tuple{S,T}) where {S<:Real, T<:Real} = (coords=v, xanchor="left", yanchor="top")
plotly_legend_pos(theta::Real) = plotly_legend_pos((theta, :inner))
plotly_legend_pos(theta::Real) = plotly_legend_pos((theta, :inner))
function plotly_legend_pos(v::Tuple{S,Symbol}) where S<:Real
(s,c) = sincosd(v[1])

View File

@ -20,5 +20,7 @@ end
Split continuous range `[-1,1]` into an integer `[1,2,3]`
"""
function legend_anchor_index(x)
return ceil(Integer,2//3*(x+1))
x<-1//3 && return 1
x<1//3 && return 2
return 3
end