Implemented legend position in plotly
This commit is contained in:
parent
e24acece49
commit
bdce27dd7b
@ -857,6 +857,7 @@ function convertLegendValue(val::Symbol)
|
|||||||
end
|
end
|
||||||
convertLegendValue(val::Bool) = val ? :best : :none
|
convertLegendValue(val::Bool) = val ? :best : :none
|
||||||
convertLegendValue(val::Void) = :none
|
convertLegendValue(val::Void) = :none
|
||||||
|
convertLegendValue{S<:Real, T<:Real}(v::Tuple{S,T}) = v
|
||||||
convertLegendValue(v::AbstractArray) = map(convertLegendValue, v)
|
convertLegendValue(v::AbstractArray) = map(convertLegendValue, v)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@ -93,6 +93,20 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
const _plotly_legend_pos = KW(
|
||||||
|
:right => [1., 0.5],
|
||||||
|
:left => [0., 0.5],
|
||||||
|
:top => [0.5, 1.],
|
||||||
|
:bottom => [0.5, 0.],
|
||||||
|
:bottomleft => [0., 0.],
|
||||||
|
:bottomright => [1., 0.],
|
||||||
|
:topright => [1., 1.],
|
||||||
|
:topleft => [0., 1.]
|
||||||
|
)
|
||||||
|
|
||||||
|
plotly_legend_pos(pos::Symbol) = get(_plotly_legend_pos, pos, [1.,1.])
|
||||||
|
plotly_legend_pos{S<:Real, T<:Real}(v::Tuple{S,T}) = v
|
||||||
|
|
||||||
function plotly_font(font::Font, color = font.color)
|
function plotly_font(font::Font, color = font.color)
|
||||||
KW(
|
KW(
|
||||||
:family => font.family,
|
:family => font.family,
|
||||||
@ -101,6 +115,7 @@ function plotly_font(font::Font, color = font.color)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function plotly_annotation_dict(x, y, val; xref="paper", yref="paper")
|
function plotly_annotation_dict(x, y, val; xref="paper", yref="paper")
|
||||||
KW(
|
KW(
|
||||||
:text => val,
|
:text => val,
|
||||||
@ -293,11 +308,14 @@ function plotly_layout(plt::Plot)
|
|||||||
|
|
||||||
# legend
|
# legend
|
||||||
d_out[:showlegend] = sp[:legend] != :none
|
d_out[:showlegend] = sp[:legend] != :none
|
||||||
|
xpos,ypos = plotly_legend_pos(sp[:legend])
|
||||||
if sp[:legend] != :none
|
if sp[:legend] != :none
|
||||||
d_out[:legend] = KW(
|
d_out[:legend] = KW(
|
||||||
:bgcolor => rgba_string(sp[:background_color_legend]),
|
:bgcolor => rgba_string(sp[:background_color_legend]),
|
||||||
:bordercolor => rgba_string(sp[:foreground_color_legend]),
|
:bordercolor => rgba_string(sp[:foreground_color_legend]),
|
||||||
:font => plotly_font(sp[:legendfont], sp[:foreground_color_legend]),
|
:font => plotly_font(sp[:legendfont], sp[:foreground_color_legend]),
|
||||||
|
:x => xpos,
|
||||||
|
:y => ypos
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user