fix aliases

This commit is contained in:
Simon Christ 2021-06-01 17:36:27 +02:00
parent c496b9c615
commit 3adfc7d404
4 changed files with 60 additions and 42 deletions

View File

@ -451,7 +451,25 @@ const _subplot_defaults = KW(
:color_palette => :auto,
:colorbar => :legend,
:clims => :auto,
:colorbar_fontfamily => :match,
:colorbar_ticks => :auto,
:colorbar_tickfontfamily => :match,
:colorbar_tickfontsize => 8,
:colorbar_tickfonthalign => :hcenter,
:colorbar_tickfontvalign => :vcenter,
:colorbar_tickfontrotation => 0.0,
:colorbar_tickfontcolor => :match,
:colorbar_scale => :identity,
:colorbar_formatter => :auto,
:colorbar_discrete_values => [],
:colorbar_continuous_values => zeros(0),
:annotations => [], # annotation tuples... list of (x,y,annotation)
:annotationfontfamily => :match,
:annotationfontsize => 14,
:annotationhalign => :hcenter,
:annotationvalign => :vcenter,
:annotationrotation => 0.0,
:annotationcolor => :match,
:projection => :none, # can also be :polar or :3d
:aspect_ratio => :auto, # choose from :none or :equal
:margin => 1mm,
@ -581,14 +599,18 @@ aliases(aliasMap::Dict{Symbol,Symbol}, val) =
# -----------------------------------------------------------------------------
# legend
add_aliases(:legend_postion, :legend)
add_aliases(:legend_background_color, :background_color_legend)
add_aliases(:legend_position, :legend, :leg, :key, :legends)
add_aliases(:legend_background_color, :bg_legend, :bglegend, :bgcolor_legend, :bg_color_legend, :background_legend,
:background_colour_legend, :bgcolour_legend, :bg_colour_legend, :background_color_legend)
add_aliases(:legend_foreground_color, :fg_legend, :fglegend, :fgcolor_legend, :fg_color_legend, :foreground_legend,
:foreground_colour_legend, :fgcolour_legend, :fg_colour_legend, :foreground_color_legend)
add_aliases(:legend_foreground_color, :foreground_color_legend)
add_aliases(:legend_font_pointsize, :legendfontsize)
add_aliases(:legend_title, :key_title, :keytitle, :label_title, :labeltitle, :leg_title, :legtitle)
add_aliases(:legend_title_font_pointsize, :legendtitlefontsize)
# margin
add_aliases(:left_margin , :leftmargin )
add_aliases(:top_margin , :topmargin)
add_aliases(:bottom_margin , :bottommargin)
add_aliases(:right_margin ,:rightmargin)
@ -603,8 +625,6 @@ add_aliases(:fillcolor, :fc, :fcolor, :fcolour, :fillcolour)
add_aliases(:background_color, :bg, :bgcolor, :bg_color, :background,
:background_colour, :bgcolour, :bg_colour)
add_aliases(:legend_background_color, :bg_legend, :bglegend, :bgcolor_legend, :bg_color_legend, :background_legend,
:background_colour_legend, :bgcolour_legend, :bg_colour_legend)
add_aliases(:background_color_subplot, :bg_subplot, :bgsubplot, :bgcolor_subplot, :bg_color_subplot, :background_subplot,
:background_colour_subplot, :bgcolour_subplot, :bg_colour_subplot)
add_aliases(:background_color_inside, :bg_inside, :bginside, :bgcolor_inside, :bg_color_inside, :background_inside,
@ -613,10 +633,11 @@ add_aliases(:background_color_outside, :bg_outside, :bgoutside, :bgcolor_outside
:background_colour_outside, :bgcolour_outside, :bg_colour_outside)
add_aliases(:foreground_color, :fg, :fgcolor, :fg_color, :foreground,
:foreground_colour, :fgcolour, :fg_colour)
add_aliases(:legend_foreground_color, :fg_legend, :fglegend, :fgcolor_legend, :fg_color_legend, :foreground_legend,
:foreground_colour_legend, :fgcolour_legend, :fg_colour_legend)
add_aliases(:foreground_color_subplot, :fg_subplot, :fgsubplot, :fgcolor_subplot, :fg_color_subplot, :foreground_subplot,
:foreground_colour_subplot, :fgcolour_subplot, :fg_colour_subplot)
add_aliases(:legend_foreground_color, :fg_legend, :fglegend, :fgcolor_legend, :fg_color_legend, :foreground_legend,
:foreground_colour_legend, :fgcolour_legend, :fg_colour_legend)
add_aliases(:foreground_color_grid, :fg_grid, :fggrid, :fgcolor_grid, :fg_color_grid, :foreground_grid,
:foreground_colour_grid, :fgcolour_grid, :fg_colour_grid, :gridcolor)
add_aliases(:foreground_color_minor_grid, :fg_minor_grid, :fgminorgrid, :fgcolor_minorgrid, :fg_color_minorgrid, :foreground_minorgrid,
@ -791,19 +812,20 @@ add_aliases(:group, :g, :grouping)
add_aliases(:bins, :bin, :nbin, :nbins, :nb)
add_aliases(:ribbon, :rib)
add_aliases(:annotations, :ann, :anns, :annotate, :annotation)
add_aliases(
:fill_z,
:fillz,
:fz,
:surfacecolor,
:surfacecolour,
:sc,
:surfcolor,
:surfcolour,
)
add_aliases(:legend, :leg, :key)
add_aliases(:legendtitle, :legend_title, :labeltitle, :label_title, :leg_title, :key_title)
add_aliases(:xguide, :xlabel, :xlab, :xl)
add_aliases(:xlims, :xlim, :xlimit, :xlimits, :xrange)
add_aliases(:xticks, :xtick)
add_aliases(:xrotation, :xrot, :xr)
add_aliases(:yguide, :ylabel, :ylab, :yl)
add_aliases(:ylims, :ylim, :ylimit, :ylimits, :yrange)
add_aliases(:yticks, :ytick)
add_aliases(:yrotation, :yrot, :yr)
add_aliases(:zguide, :zlabel, :zlab, :zl)
add_aliases(:zlims, :zlim, :zlimit, :zlimits)
add_aliases(:zticks, :ztick)
add_aliases(:zrotation, :zrot, :zr)
add_aliases(:guidefontsize, :labelfontsize)
add_aliases(:fill_z, :fillz, :fz, :surfacecolor, :surfacecolour, :sc, :surfcolor, :surfcolour)
add_aliases(:colorbar, :cb, :cbar, :colorkey)
add_aliases(
:colorbar_title,

View File

@ -800,30 +800,27 @@ function pgfx_get_legend_pos(v::Tuple{S,Symbol}) where {S<:Real}
end
function pgfx_get_legend_style(sp)
cstr = plot_color(sp[:background_color_legend])
cstr = plot_color(sp[:legend_background_color])
a = alpha(cstr)
fg_alpha = alpha(plot_color(sp[:foreground_color_legend]))
fg_alpha = alpha(plot_color(sp[:legend_foreground_color]))
legfont = legendfont(sp)
PGFPlotsX.Options(
pgfx_linestyle(
pgfx_thickness_scaling(sp),
sp[:foreground_color_legend],
sp[:legend_foreground_color],
fg_alpha,
"solid",
) => nothing,
"fill" => cstr,
"fill opacity" => a,
"text opacity" => alpha(plot_color(sp[:legendfontcolor])),
"font" => pgfx_font(sp[:legendfontsize], pgfx_thickness_scaling(sp)),
"text" => plot_color(sp[:legendfontcolor]),
"cells" => PGFPlotsX.Options(
"anchor" => get(
(left = "west", right = "east", hcenter = "center"),
legfont.halign,
"west",
"text opacity" => alpha(plot_color(sp[:legend_font_color])),
"font" => pgfx_font(
sp[:legend_font_pointsize],
pgfx_thickness_scaling(sp),
),
),
pgfx_get_legend_pos(sp[:legend])...,
"text" => plot_color(sp[:legend_font_color]),
"cells" => PGFPlotsX.Options("anchor" => get((left = "west", right = "east", hcenter = "center"), legfont.halign, "west")),
pgfx_get_legend_pos(sp[:legend_position])...,
)
end

View File

@ -23,7 +23,7 @@ function RecipesPipeline.warn_on_recipe_aliases!(
else
throw(ArgumentError("Invalid recipe type `$recipe_type`"))
end
@warn "Attribute alias `$k` detected in the $recipe_type recipe defined for the signature $signature_string. To ensure expected behavior it is recommended to use the default attribute `$dk`."
# @warn "Attribute alias `$k` detected in the $recipe_type recipe defined for the signature $signature_string. To ensure expected behavior it is recommended to use the default attribute `$dk`."
end
plotattributes[dk] = RecipesPipeline.pop_kw!(plotattributes, k)
end

View File

@ -56,11 +56,10 @@ end # testset
@test p[1][:legend_font_halign] == :left
@test p[1][:legend_font_valign] == :top
@test p[1][:legend_font_rotation] == 1.0
# This propagates :red
@test_broken p[1][:legend_font_color] == RGB{Colors.N0f8}(1.0,0.0,0.0)
# FIXME: this doesn't get set
@test_broken p[1][:legend_position] == :outertopleft
# FIXME: this doesn't get set
@test_broken p[1][:legend_title] == "The legend"
@test p[1][:legend_position] == :outertopleft
@test p[1][:legend_title] == "The legend"
@test p[1][:legend_title_font_family] == "helvetica"
@test p[1][:legend_title_font_pointsize] == 3
@test p[1][:legend_title_font_halign] == :right