prototype

This commit is contained in:
Simon Christ 2020-11-12 12:04:22 +01:00 committed by Simon Christ
parent 8f055fef3d
commit 4ab9dc17f5
3 changed files with 27 additions and 0 deletions

View File

@ -1273,12 +1273,16 @@ function convertLegendValue(val::Symbol)
:none :none
elseif val in (:right, :left, :top, :bottom, :inside, :best, :legend, :topright, :topleft, :bottomleft, :bottomright, :outertopright, :outertopleft, :outertop, :outerright, :outerleft, :outerbottomright, :outerbottomleft, :outerbottom, :inline) elseif val in (:right, :left, :top, :bottom, :inside, :best, :legend, :topright, :topleft, :bottomleft, :bottomright, :outertopright, :outertopleft, :outertop, :outerright, :outerleft, :outerbottomright, :outerbottomleft, :outerbottom, :inline)
val val
elseif val == :horizontal
-1
else else
error("Invalid symbol for legend: $val") error("Invalid symbol for legend: $val")
end end
end end
convertLegendValue(val::Real) = val
convertLegendValue(val::Bool) = val ? :best : :none convertLegendValue(val::Bool) = val ? :best : :none
convertLegendValue(val::Nothing) = :none convertLegendValue(val::Nothing) = :none
convertLegendValue(v::Union{Tuple, NamedTuple}) = convertLegendValue.(v)
convertLegendValue(v::Tuple{S,T}) where {S<:Real, T<:Real} = v convertLegendValue(v::Tuple{S,T}) where {S<:Real, T<:Real} = v
convertLegendValue(v::Tuple{<:Real,Symbol}) = v convertLegendValue(v::Tuple{<:Real,Symbol}) = v
convertLegendValue(v::Real) = v convertLegendValue(v::Real) = v

View File

@ -140,6 +140,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
axis_opt = PGFPlotsX.Options( axis_opt = PGFPlotsX.Options(
"point meta max" => get_clims(sp)[2], "point meta max" => get_clims(sp)[2],
"point meta min" => get_clims(sp)[1], "point meta min" => get_clims(sp)[1],
"legend cell align" => "left",
"legend columns" => pgfx_legend_col(sp[:legend]),
"title" => sp[:title], "title" => sp[:title],
"title style" => PGFPlotsX.Options( "title style" => PGFPlotsX.Options(
pgfx_get_title_pos(title_loc)..., pgfx_get_title_pos(title_loc)...,
@ -918,6 +920,15 @@ function pgfx_linestyle(linewidth::Real, color, α = 1, linestyle = :solid)
) )
end end
function pgfx_legend_col(s::Symbol)
if s == :horizontal
return -1
end
return 1
end
pgfx_legend_col(n) = n
function pgfx_linestyle(plotattributes, i = 1) function pgfx_linestyle(plotattributes, i = 1)
lw = pgfx_thickness_scaling(plotattributes) * get_linewidth(plotattributes, i) lw = pgfx_thickness_scaling(plotattributes) * get_linewidth(plotattributes, i)
lc = single_color(get_linecolor(plotattributes, i)) lc = single_color(get_linecolor(plotattributes, i))

View File

@ -777,3 +777,15 @@ function extrema_plus_buffer(v, buffmult = 0.2)
buffer = vdiff * buffmult buffer = vdiff * buffmult
vmin - buffer, vmax + buffer vmin - buffer, vmax + buffer
end end
### Legend
@add_annotations subplot struct Legend
background_color
foreground_color
position
title
font::Font # TODO: check if macro is recursive enough
title_font
column
end