diff --git a/src/arg_desc.jl b/src/arg_desc.jl index 7bad0950..f7a6f4ed 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -76,52 +76,52 @@ const _arg_desc = KW( :fontfamily => "String or Symbol. Default font family for title, legend entries, tick labels and guides", :warn_on_unsupported => "Bool. Warn on unsupported attributes, series types and marker shapes", -# subplot args -:title => "String. Subplot title.", -:titlelocation => "Symbol. Position of subplot title. Values: `:left`, `:center`, `:right`", -:titlefontfamily => "String or Symbol. Font family of subplot title.", -:titlefontsize => "Integer. Font pointsize of subplot title.", -:titlefonthalign => "Symbol. Font horizontal alignment of subplot title: :hcenter, :left, :right or :center", -:titlefontvalign => "Symbol. Font vertical alignment of subplot title: :vcenter, :top, :bottom or :center", -:titlefontrotation => "Real. Font rotation of subplot title", -:titlefontcolor => "Color Type. Font color of subplot title", -:background_color_subplot => "Color Type or `:match` (matches `:background_color`). Base background color of the subplot.", -:legend_background_color => "Color Type or `:match` (matches `:background_color_subplot`). Background color of the legend.", -:background_color_inside => "Color Type or `:match` (matches `:background_color_subplot`). Background color inside the plot area (under the grid).", -:foreground_color_subplot => "Color Type or `:match` (matches `:foreground_color`). Base foreground color of the subplot.", -:legend_foreground_color => "Color Type or `:match` (matches `:foreground_color_subplot`). Foreground color of the legend.", -:foreground_color_title => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of subplot title.", -:color_palette => "Vector of colors (cycle through) or color gradient (generate list from gradient) or `:auto` (generate a color list using `Colors.distiguishable_colors` and custom seed colors chosen to contrast with the background). The color palette is a color list from which series colors are automatically chosen.", -:legend => "Bool (show the legend?) or (x,y) tuple or Symbol (legend position). Bottom left corner of legend is placed at (x,y). Symbol values: `:none`; `:best`; `:inline`; `:inside`; `:legend`; any valid combination of `:(outer ?)(top/bottom ?)(right/left ?)`, i.e.: `:top`, `:topright`, `:outerleft`, `:outerbottomright` ... (note: only some may be supported in each backend)", -:legend_font_family => "String or Symbol. Font family of legend entries.", -:legend_font_pointsize => "Integer. Font pointsize of legend entries.", -:legend_font_halign => "Symbol. Font horizontal alignment of legend entries: :hcenter, :left, :right or :center", -:legend_font_valign => "Symbol. Font vertical alignment of legend entries: :vcenter, :top, :bottom or :center", -:legend_font_rotation => "Real. Font rotation of legend entries", -:legend_font_color => "Color Type. Font color of legend entries", -:legend_title => "String. Legend title.", -:legend_title_font_family => "String or Symbol. Font family of the legend title.", -:legend_title_font_pointsize => "Integer. Font pointsize the legend title.", -:legend_title_font_halign => "Symbol. Font horizontal alignment of the legend title: :hcenter, :left, :right or :center", -:legend_title_font_valign => "Symbol. Font vertical alignment of the legend title: :vcenter, :top, :bottom or :center", -:legend_title_font_rotation => "Real. Font rotation of the legend title", -:legend_title_font_color => "Color Type. Font color of the legend title", -:colorbar => "Bool (show the colorbar?) or Symbol (colorbar position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:legend` (matches legend value) (note: only some may be supported in each backend)", -:clims => "`:auto`, NTuple{2,Number}, or a function that takes series data in and returns NTuple{2,Number}. Fixes the limits of the colorbar.", -:legendfont => "Font. Font of legend items.", -:legend_titlefont => "Font. Font of the legend title.", -:annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String or PlotText (created with `text(args...)`) Add one-off text annotations at the x,y coordinates.", -:projection => "Symbol or String. '3d' or 'polar'", -:aspect_ratio => "Symbol (:equal or :none) or Number. Plot area is resized so that 1 y-unit is the same size as `aspect_ratio` x-units. With `:none`, images inherit aspect ratio of the plot area.", -:margin => "Measure (multiply by `mm`, `px`, etc). Base for individual margins... not directly used. Specifies the extra padding around subplots.", -:left_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the left of the subplot.", -:top_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the top of the subplot.", -:right_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the right of the subplot.", -:bottom_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the bottom of the subplot.", -:subplot_index => "Integer. Internal (not set by user). Specifies the index of this subplot in the Plot's `plt.subplot` list.", -:colorbar_title => "String. Title of colorbar.", -:framestyle => "Symbol. Style of the axes frame. Choose from $(_allFramestyles)", -:camera => "NTuple{2, Real}. Sets the view angle (azimuthal, elevation) for 3D plots", + # subplot args + :title => "String. Subplot title.", + :titlelocation => "Symbol. Position of subplot title. Values: `:left`, `:center`, `:right`", + :titlefontfamily => "String or Symbol. Font family of subplot title.", + :titlefontsize => "Integer. Font pointsize of subplot title.", + :titlefonthalign => "Symbol. Font horizontal alignment of subplot title: :hcenter, :left, :right or :center", + :titlefontvalign => "Symbol. Font vertical alignment of subplot title: :vcenter, :top, :bottom or :center", + :titlefontrotation => "Real. Font rotation of subplot title", + :titlefontcolor => "Color Type. Font color of subplot title", + :background_color_subplot => "Color Type or `:match` (matches `:background_color`). Base background color of the subplot.", + :legend_background_color => "Color Type or `:match` (matches `:background_color_subplot`). Background color of the legend.", + :background_color_inside => "Color Type or `:match` (matches `:background_color_subplot`). Background color inside the plot area (under the grid).", + :foreground_color_subplot => "Color Type or `:match` (matches `:foreground_color`). Base foreground color of the subplot.", + :legend_foreground_color => "Color Type or `:match` (matches `:foreground_color_subplot`). Foreground color of the legend.", + :foreground_color_title => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of subplot title.", + :color_palette => "Vector of colors (cycle through) or color gradient (generate list from gradient) or `:auto` (generate a color list using `Colors.distiguishable_colors` and custom seed colors chosen to contrast with the background). The color palette is a color list from which series colors are automatically chosen.", + :legend => "Bool (show the legend?) or (x,y) tuple or Symbol (legend position). Bottom left corner of legend is placed at (x,y). Symbol values: `:none`; `:best`; `:inline`; `:inside`; `:legend`; any valid combination of `:(outer ?)(top/bottom ?)(right/left ?)`, i.e.: `:top`, `:topright`, `:outerleft`, `:outerbottomright` ... (note: only some may be supported in each backend)", + :legend_font_family => "String or Symbol. Font family of legend entries.", + :legend_font_pointsize => "Integer. Font pointsize of legend entries.", + :legend_font_halign => "Symbol. Font horizontal alignment of legend entries: :hcenter, :left, :right or :center", + :legend_font_valign => "Symbol. Font vertical alignment of legend entries: :vcenter, :top, :bottom or :center", + :legend_font_rotation => "Real. Font rotation of legend entries", + :legend_font_color => "Color Type. Font color of legend entries", + :legend_title => "String. Legend title.", + :legend_title_font_family => "String or Symbol. Font family of the legend title.", + :legend_title_font_pointsize => "Integer. Font pointsize the legend title.", + :legend_title_font_halign => "Symbol. Font horizontal alignment of the legend title: :hcenter, :left, :right or :center", + :legend_title_font_valign => "Symbol. Font vertical alignment of the legend title: :vcenter, :top, :bottom or :center", + :legend_title_font_rotation => "Real. Font rotation of the legend title", + :legend_title_font_color => "Color Type. Font color of the legend title", + :colorbar => "Bool (show the colorbar?) or Symbol (colorbar position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:legend` (matches legend value) (note: only some may be supported in each backend)", + :clims => "`:auto`, NTuple{2,Number}, or a function that takes series data in and returns NTuple{2,Number}. Fixes the limits of the colorbar.", + :legendfont => "Font. Font of legend items.", + :legend_titlefont => "Font. Font of the legend title.", + :annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String or PlotText (created with `text(args...)`) Add one-off text annotations at the x,y coordinates.", + :projection => "Symbol or String. '3d' or 'polar'", + :aspect_ratio => "Symbol (:equal or :none) or Number. Plot area is resized so that 1 y-unit is the same size as `aspect_ratio` x-units. With `:none`, images inherit aspect ratio of the plot area.", + :margin => "Measure (multiply by `mm`, `px`, etc). Base for individual margins... not directly used. Specifies the extra padding around subplots.", + :left_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the left of the subplot.", + :top_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the top of the subplot.", + :right_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the right of the subplot.", + :bottom_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the bottom of the subplot.", + :subplot_index => "Integer. Internal (not set by user). Specifies the index of this subplot in the Plot's `plt.subplot` list.", + :colorbar_title => "String. Title of colorbar.", + :framestyle => "Symbol. Style of the axes frame. Choose from $(_allFramestyles)", + :camera => "NTuple{2, Real}. Sets the view angle (azimuthal, elevation) for 3D plots", # axis args :guide => "String. Axis guide (label).", diff --git a/src/args.jl b/src/args.jl index 3acbe12d..89b8b858 100644 --- a/src/args.jl +++ b/src/args.jl @@ -435,61 +435,61 @@ const _plot_defaults = KW( ) const _subplot_defaults = KW( - :title => "", - :titlelocation => :center, # also :left or :right - :fontfamily_subplot => :match, - :titlefontfamily => :match, - :titlefontsize => 14, - :titlefonthalign => :hcenter, - :titlefontvalign => :vcenter, - :titlefontrotation => 0.0, - :titlefontcolor => :match, + :title => "", + :titlelocation => :center, # also :left or :right + :fontfamily_subplot => :match, + :titlefontfamily => :match, + :titlefontsize => 14, + :titlefonthalign => :hcenter, + :titlefontvalign => :vcenter, + :titlefontrotation => 0.0, + :titlefontcolor => :match, :background_color_subplot => :match, # default for other bg colors... match takes plot default - :background_color_inside => :match, # background inside grid + :background_color_inside => :match, # background inside grid :foreground_color_subplot => :match, # default for other fg colors... match takes plot default - :foreground_color_title => :match, # title color - :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, - :left_margin => :match, - :top_margin => :match, - :right_margin => :match, - :bottom_margin => :match, - :subplot_index => -1, - :colorbar_title => "", - :colorbar_titlefontsize => 10, - :colorbar_title_location => :center, # also :left or :right - :colorbar_fontfamily => :match, - :colorbar_titlefontfamily => :match, - :colorbar_titlefonthalign => :hcenter, - :colorbar_titlefontvalign => :vcenter, - :colorbar_titlefontrotation => 0.0, - :colorbar_titlefontcolor => :match, - :framestyle => :axes, - :camera => (30,30), - :extra_kwargs => Dict() + :foreground_color_title => :match, # title color + :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, + :left_margin => :match, + :top_margin => :match, + :right_margin => :match, + :bottom_margin => :match, + :subplot_index => -1, + :colorbar_title => "", + :colorbar_titlefontsize => 10, + :colorbar_title_location => :center, # also :left or :right + :colorbar_fontfamily => :match, + :colorbar_titlefontfamily => :match, + :colorbar_titlefonthalign => :hcenter, + :colorbar_titlefontvalign => :vcenter, + :colorbar_titlefontrotation => 0.0, + :colorbar_titlefontcolor => :match, + :framestyle => :axes, + :camera => (30, 30), + :extra_kwargs => Dict(), ) const _axis_defaults = KW( @@ -551,7 +551,6 @@ const _suppress_warnings = Set{Symbol}([ :relative_bbox, ]) - is_subplot_attr(k) = k in _all_subplot_args is_series_attr(k) = k in _all_series_args is_axis_attr(k) = Symbol(chop(string(k); head = 1, tail = 0)) in _all_axis_args @@ -585,19 +584,47 @@ aliases(aliasMap::Dict{Symbol,Symbol}, val) = # ----------------------------------------------------------------------------- # 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_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_font_pointsize, :legendfontsize) -add_aliases(:legend_title, :key_title, :keytitle, :label_title, :labeltitle, :leg_title, :legtitle) +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(:left_margin, :leftmargin) -add_aliases(:top_margin , :topmargin) -add_aliases(:bottom_margin , :bottommargin) -add_aliases(:right_margin ,:rightmargin) +add_aliases(:top_margin, :topmargin) +add_aliases(:bottom_margin, :bottommargin) +add_aliases(:right_margin, :rightmargin) # colors add_aliases(:seriescolor, :c, :color, :colour) @@ -607,33 +634,155 @@ add_aliases(:markerstrokecolor, :msc, :mscolor, :mscolour, :markerstrokecolour) add_aliases(:markerstrokewidth, :msw, :mswidth) add_aliases(:fillcolor, :fc, :fcolor, :fcolour, :fillcolour) -add_aliases(:background_color, :bg, :bgcolor, :bg_color, :background, - :background_colour, :bgcolour, :bg_colour) -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, - :background_colour_inside, :bgcolour_inside, :bg_colour_inside) -add_aliases(:background_color_outside, :bg_outside, :bgoutside, :bgcolor_outside, :bg_color_outside, :background_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( + :background_color, + :bg, + :bgcolor, + :bg_color, + :background, + :background_colour, + :bgcolour, + :bg_colour, +) +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, + :background_colour_inside, + :bgcolour_inside, + :bg_colour_inside, +) +add_aliases( + :background_color_outside, + :bg_outside, + :bgoutside, + :bgcolor_outside, + :bg_color_outside, + :background_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(:foreground_color_subplot, :fg_subplot, :fgsubplot, :fgcolor_subplot, :fg_color_subplot, :foreground_subplot, - :foreground_colour_subplot, :fgcolour_subplot, :fg_colour_subplot) -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, - :foreground_colour_minor_grid, :fgcolour_minorgrid, :fg_colour_minor_grid, :minorgridcolor) -add_aliases(:foreground_color_title, :fg_title, :fgtitle, :fgcolor_title, :fg_color_title, :foreground_title, - :foreground_colour_title, :fgcolour_title, :fg_colour_title, :titlecolor) -add_aliases(:foreground_color_axis, :fg_axis, :fgaxis, :fgcolor_axis, :fg_color_axis, :foreground_axis, - :foreground_colour_axis, :fgcolour_axis, :fg_colour_axis, :axiscolor) -add_aliases(:foreground_color_border, :fg_border, :fgborder, :fgcolor_border, :fg_color_border, :foreground_border, - :foreground_colour_border, :fgcolour_border, :fg_colour_border, :bordercolor) -add_aliases(:foreground_color_text, :fg_text, :fgtext, :fgcolor_text, :fg_color_text, :foreground_text, - :foreground_colour_text, :fgcolour_text, :fg_colour_text, :textcolor) -add_aliases(:foreground_color_guide, :fg_guide, :fgguide, :fgcolor_guide, :fg_color_guide, :foreground_guide, - :foreground_colour_guide, :fgcolour_guide, :fg_colour_guide, :guidecolor) +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( + :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, + :foreground_colour_minor_grid, + :fgcolour_minorgrid, + :fg_colour_minor_grid, + :minorgridcolor, +) +add_aliases( + :foreground_color_title, + :fg_title, + :fgtitle, + :fgcolor_title, + :fg_color_title, + :foreground_title, + :foreground_colour_title, + :fgcolour_title, + :fg_colour_title, + :titlecolor, +) +add_aliases( + :foreground_color_axis, + :fg_axis, + :fgaxis, + :fgcolor_axis, + :fg_color_axis, + :foreground_axis, + :foreground_colour_axis, + :fgcolour_axis, + :fg_colour_axis, + :axiscolor, +) +add_aliases( + :foreground_color_border, + :fg_border, + :fgborder, + :fgcolor_border, + :fg_color_border, + :foreground_border, + :foreground_colour_border, + :fgcolour_border, + :fg_colour_border, + :bordercolor, +) +add_aliases( + :foreground_color_text, + :fg_text, + :fgtext, + :fgcolor_text, + :fg_color_text, + :foreground_text, + :foreground_colour_text, + :fgcolour_text, + :fg_colour_text, + :textcolor, +) +add_aliases( + :foreground_color_guide, + :fg_guide, + :fgguide, + :fgcolor_guide, + :fg_color_guide, + :foreground_guide, + :foreground_colour_guide, + :fgcolour_guide, + :fg_colour_guide, + :guidecolor, +) add_aliases( :foreground_color_title, @@ -807,7 +956,16 @@ 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( + :fill_z, + :fillz, + :fz, + :surfacecolor, + :surfacecolour, + :sc, + :surfcolor, + :surfcolour, +) add_aliases(:colorbar, :cb, :cbar, :colorkey) add_aliases( :colorbar_title, @@ -895,7 +1053,6 @@ function parse_axis_kw(s::Symbol) return nothing end - # update the defaults globally """ @@ -1393,7 +1550,8 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) # legends if haskey(plotattributes, :legend_position) - plotattributes[:legend_position] = convertLegendValue(plotattributes[:legend_position]) + plotattributes[:legend_position] = + convertLegendValue(plotattributes[:legend_position]) end if haskey(plotattributes, :colorbar) plotattributes[:colorbar] = convertLegendValue(plotattributes[:colorbar]) @@ -1533,8 +1691,8 @@ end convertLegendValue(val::Real) = val convertLegendValue(val::Bool) = val ? :best : :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::Union{Tuple,NamedTuple}) = convertLegendValue.(v) +convertLegendValue(v::Tuple{S,T}) where {S<:Real,T<:Real} = v convertLegendValue(v::Tuple{<:Real,Symbol}) = v convertLegendValue(v::AbstractArray) = map(convertLegendValue, v) @@ -2146,13 +2304,14 @@ function _splitdef!(blk, key_dict) elseif lhs isa Expr && lhs.head === :(::) && lhs.args[1] isa Symbol # var::T = defexpr var = lhs.args[1] - type = lhs.args[2] + type = lhs.args[2] if @isdefined type for field in fieldnames(getproperty(Plots, type)) - key_dict[Symbol(var, "_", field)] = :(getfield($(ei.args[2]), $(QuoteNode(field)))) + key_dict[Symbol(var, "_", field)] = + :(getfield($(ei.args[2]), $(QuoteNode(field)))) end end - else + else # something else, e.g. inline inner constructor # F(...) = ... continue diff --git a/src/backends.jl b/src/backends.jl index 979f2643..63e1c3d9 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -310,9 +310,14 @@ _initialize_backend(pkg::GRBackend) = nothing const _gr_attr = merge_with_base_supported([ :annotations, - :legend_background_color, :background_color_inside, :background_color_outside, - :legend_foreground_color, :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, + :legend_background_color, + :background_color_inside, + :background_color_outside, + :legend_foreground_color, + :foreground_color_grid, + :foreground_color_axis, + :foreground_color_text, + :foreground_color_border, :label, :seriescolor, :seriesalpha, @@ -332,20 +337,52 @@ const _gr_attr = merge_with_base_supported([ :fillalpha, :bins, :layout, - :title, :window_title, - :guide, :lims, :ticks, :scale, :flip, - :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, - :titlefontrotation, :titlefontcolor, - :legend_font_family, :legend_font_pointsize, :legend_font_halign, :legend_font_valign, - :legend_font_rotation, :legend_font_color, - :tickfontfamily, :tickfontsize, :tickfonthalign, :tickfontvalign, - :tickfontrotation, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign, - :guidefontrotation, :guidefontcolor, - :grid, :gridalpha, :gridstyle, :gridlinewidth, - :legend_position, :legend_title, :colorbar, :colorbar_title, :colorbar_entry, - :fill_z, :line_z, :marker_z, :levels, - :ribbon, :quiver, + :title, + :window_title, + :guide, + :lims, + :ticks, + :scale, + :flip, + :titlefontfamily, + :titlefontsize, + :titlefonthalign, + :titlefontvalign, + :titlefontrotation, + :titlefontcolor, + :legend_font_family, + :legend_font_pointsize, + :legend_font_halign, + :legend_font_valign, + :legend_font_rotation, + :legend_font_color, + :tickfontfamily, + :tickfontsize, + :tickfonthalign, + :tickfontvalign, + :tickfontrotation, + :tickfontcolor, + :guidefontfamily, + :guidefontsize, + :guidefonthalign, + :guidefontvalign, + :guidefontrotation, + :guidefontcolor, + :grid, + :gridalpha, + :gridstyle, + :gridlinewidth, + :legend_position, + :legend_title, + :colorbar, + :colorbar_title, + :colorbar_entry, + :fill_z, + :line_z, + :marker_z, + :levels, + :ribbon, + :quiver, :orientation, :overwrite_figure, :polar, @@ -396,10 +433,15 @@ end const _plotly_attr = merge_with_base_supported([ :annotations, - :legend_background_color, :background_color_inside, :background_color_outside, - :legend_foreground_color, :foreground_color_guide, - :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, + :legend_background_color, + :background_color_inside, + :background_color_outside, + :legend_foreground_color, + :foreground_color_guide, + :foreground_color_grid, + :foreground_color_axis, + :foreground_color_text, + :foreground_color_border, :foreground_color_title, :label, :seriescolor, @@ -427,9 +469,15 @@ const _plotly_attr = merge_with_base_supported([ :titlefonthalign, :titlefontvalign, :titlefontcolor, - :legend_font_family, :legend_font_pointsize, :legend_font_color, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, + :legend_font_family, + :legend_font_pointsize, + :legend_font_color, + :tickfontfamily, + :tickfontsize, + :tickfontcolor, + :guidefontfamily, + :guidefontsize, + :guidefontcolor, :window_title, :guide, :lims, @@ -515,8 +563,10 @@ const _pgfplots_attr = merge_with_base_supported([ :background_color_inside, # :background_color_outside, # :legend_foreground_color, - :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, + :foreground_color_grid, + :foreground_color_axis, + :foreground_color_text, + :foreground_color_border, :label, :seriescolor, :seriesalpha, @@ -632,9 +682,16 @@ end const _pyplot_attr = merge_with_base_supported([ :annotations, - :legend_background_color, :background_color_inside, :background_color_outside, - :foreground_color_grid, :legend_foreground_color, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :legend_background_color, + :background_color_inside, + :background_color_outside, + :foreground_color_grid, + :legend_foreground_color, + :foreground_color_title, + :foreground_color_axis, + :foreground_color_border, + :foreground_color_guide, + :foreground_color_text, :label, :linecolor, :linestyle, @@ -658,16 +715,41 @@ const _pyplot_attr = merge_with_base_supported([ :titlelocation, :titlefont, :window_title, - :guide, :guide_position, :lims, :ticks, :scale, :flip, :rotation, - :titlefontfamily, :titlefontsize, :titlefontcolor, - :legend_font_family, :legend_font_pointsize, :legend_font_color, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, - :grid, :gridalpha, :gridstyle, :gridlinewidth, - :legend_position, :legend_title, :colorbar, :colorbar_title, :colorbar_entry, - :colorbar_ticks, :colorbar_tickfontfamily, :colorbar_tickfontsize, - :colorbar_tickfonthalign, :colorbar_tickfontvalign, - :colorbar_tickfontrotation, :colorbar_tickfontcolor, + :guide, + :guide_position, + :lims, + :ticks, + :scale, + :flip, + :rotation, + :titlefontfamily, + :titlefontsize, + :titlefontcolor, + :legend_font_family, + :legend_font_pointsize, + :legend_font_color, + :tickfontfamily, + :tickfontsize, + :tickfontcolor, + :guidefontfamily, + :guidefontsize, + :guidefontcolor, + :grid, + :gridalpha, + :gridstyle, + :gridlinewidth, + :legend_position, + :legend_title, + :colorbar, + :colorbar_title, + :colorbar_entry, + :colorbar_ticks, + :colorbar_tickfontfamily, + :colorbar_tickfontsize, + :colorbar_tickfonthalign, + :colorbar_tickfontvalign, + :colorbar_tickfontrotation, + :colorbar_tickfontcolor, :colorbar_scale, :marker_z, :line_z, @@ -893,9 +975,16 @@ const _canvas_type = Ref(:auto) const _hdf5_attr = merge_with_base_supported([ :annotations, - :legend_background_color, :background_color_inside, :background_color_outside, - :foreground_color_grid, :legend_foreground_color, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :legend_background_color, + :background_color_inside, + :background_color_outside, + :foreground_color_grid, + :legend_foreground_color, + :foreground_color_title, + :foreground_color_axis, + :foreground_color_border, + :foreground_color_guide, + :foreground_color_text, :label, :linecolor, :linestyle, @@ -988,10 +1077,16 @@ const HDF5PLOT_PLOTREF = HDF5Plot_PlotRef(nothing) const _inspectdr_attr = merge_with_base_supported([ :annotations, - :legend_background_color, :background_color_inside, :background_color_outside, + :legend_background_color, + :background_color_inside, + :background_color_outside, # :foreground_color_grid, - :legend_foreground_color, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :legend_foreground_color, + :foreground_color_title, + :foreground_color_axis, + :foreground_color_border, + :foreground_color_guide, + :foreground_color_text, :label, :seriescolor, :seriesalpha, @@ -1013,17 +1108,28 @@ const _inspectdr_attr = merge_with_base_supported([ :title, :titlelocation, :window_title, - :guide, :lims, :scale, #:ticks, :flip, :rotation, - :titlefontfamily, :titlefontsize, :titlefontcolor, - :legend_font_family, :legend_font_pointsize, :legend_font_color, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, - :grid, :legend_position, #:colorbar, -# :marker_z, -# :line_z, -# :levels, - # :ribbon, :quiver, :arrow, -# :orientation, + :guide, + :lims, + :scale, #:ticks, :flip, :rotation, + :titlefontfamily, + :titlefontsize, + :titlefontcolor, + :legend_font_family, + :legend_font_pointsize, + :legend_font_color, + :tickfontfamily, + :tickfontsize, + :tickfontcolor, + :guidefontfamily, + :guidefontsize, + :guidefontcolor, + :grid, + :legend_position, #:colorbar, + # :marker_z, + # :line_z, + # :levels, + # :ribbon, :quiver, :arrow, + # :orientation, :overwrite_figure, :polar, # :normalize, :weights, diff --git a/src/components.jl b/src/components.jl index 31e5702d..d2f89bc0 100644 --- a/src/components.jl +++ b/src/components.jl @@ -783,4 +783,9 @@ end font::Font = font(8) title_font::Font = font(11) column = 1 -end :match = (:legend_font_family, :legend_font_color, :legend_title_font_family, :legend_title_font_color) +end :match = ( + :legend_font_family, + :legend_font_color, + :legend_title_font_family, + :legend_title_font_color, +) diff --git a/src/consts.jl b/src/consts.jl index b9c8cde5..c94f7aab 100644 --- a/src/consts.jl +++ b/src/consts.jl @@ -47,13 +47,8 @@ const _subplot_args = sort(union(collect(keys(_subplot_defaults)))) const _plot_args = sort(union(collect(keys(_plot_defaults)))) const _magic_axis_args = [:axis, :tickfont, :guidefont, :grid, :minorgrid] -const _magic_subplot_args = [ - :title_font, - :legend_font, - :legend_title_font, - :plot_title_font, - :colorbar_titlefont, -] +const _magic_subplot_args = + [:title_font, :legend_font, :legend_title_font, :plot_title_font, :colorbar_titlefont] const _magic_series_args = [:line, :marker, :fill] const _all_axis_args = sort(union([_axis_args; _magic_axis_args])) @@ -75,7 +70,7 @@ end # fill symbol cache for letter in (:x, :y, :z) - _attrsymbolcache[letter] = Dict{Symbol, Symbol}() + _attrsymbolcache[letter] = Dict{Symbol,Symbol}() for k in _axis_args # populate attribute cache lk = Symbol(letter, k)