Legend overhaul including horizontal legends (#2854)
* prototype
* use add_attributes macro with modification
* add Colors back
* fix convertLegendValue
* fix legendtitlefontsize
* fix gr legend position
* fix aliases
* symbolic color is okay
* remove redundant legend_forground_color aliases
* legend -> legend_postion
* fix inspectdr
* add legendtitlefont pointsize and color
* fix symbol cache
* fix rebase woes
* Update precompile_*.jl file [skip ci] (#3885)
Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>
* fix gr
* more fixes
* add match_table to `@add_attributes`
* fix match_map
* Update src/backends/pgfplotsx.jl
Co-authored-by: t-bltg <tf.bltg@gmail.com>
* fix font calls
* apply formatter
* readd descriptions
* more missing descriptions
* adjust pyplot to master
* fix pgfplotsx
* Revert "Merge branch 'bbs/horizontal-legends' of https://github.com/JuliaPlots/Plots.jl into bbs/horizontal-legends"
This reverts commit d880d89ef6.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>
Co-authored-by: t-bltg <tf.bltg@gmail.com>
This commit is contained in:
@@ -65,6 +65,9 @@ end
|
||||
end
|
||||
|
||||
@testset "axis-aliases" begin
|
||||
@test haskey(Plots._keyAliases, :xguideposition)
|
||||
@test haskey(Plots._keyAliases, :x_guide_position)
|
||||
@test !haskey(Plots._keyAliases, :xguide_position)
|
||||
p = plot(1:2, xl = "x label")
|
||||
@test p[1][:xaxis][:guide] === "x label"
|
||||
p = plot(1:2, xrange = (0, 3))
|
||||
|
||||
+58
-1
@@ -1,4 +1,4 @@
|
||||
using Plots, Test
|
||||
using Plots, Test, Colors
|
||||
|
||||
const PLOTS_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino)
|
||||
Plots.__init__()
|
||||
@@ -11,3 +11,60 @@ end
|
||||
|
||||
empty!(PLOTS_DEFAULTS)
|
||||
Plots.__init__()
|
||||
|
||||
@testset "Legend defaults" begin
|
||||
p = plot()
|
||||
@test p[1][:legend_font_family] == "sans-serif"
|
||||
@test p[1][:legend_font_pointsize] == 8
|
||||
@test p[1][:legend_font_halign] == :hcenter
|
||||
@test p[1][:legend_font_valign] == :vcenter
|
||||
@test p[1][:legend_font_rotation] == 0.0
|
||||
@test p[1][:legend_font_color] == RGB{Colors.N0f8}(0.0,0.0,0.0)
|
||||
@test p[1][:legend_position] == :best
|
||||
@test p[1][:legend_title] == nothing
|
||||
@test p[1][:legend_title_font_family] == "sans-serif"
|
||||
@test p[1][:legend_title_font_pointsize] == 11
|
||||
@test p[1][:legend_title_font_halign] == :hcenter
|
||||
@test p[1][:legend_title_font_valign] == :vcenter
|
||||
@test p[1][:legend_title_font_rotation] == 0.0
|
||||
@test p[1][:legend_title_font_color] == RGB{Colors.N0f8}(0.0,0.0,0.0)
|
||||
@test p[1][:legend_background_color] == RGBA{Float64}(1.0,1.0,1.0,1.0)
|
||||
@test p[1][:legend_foreground_color] == RGB{Colors.N0f8}(0.0,0.0,0.0)
|
||||
end # testset
|
||||
|
||||
@testset "Legend API" begin
|
||||
p = plot(;
|
||||
legendfontfamily = "serif",
|
||||
legendfontsize = 12,
|
||||
legendfonthalign = :left,
|
||||
legendfontvalign = :top,
|
||||
legendfontrotation = 1,
|
||||
legendfontcolor = :red,
|
||||
legend = :outertopleft,
|
||||
legendtitle = "The legend",
|
||||
legendtitlefontfamily = "helvetica",
|
||||
legendtitlefontsize = 3,
|
||||
legendtitlefonthalign = :right,
|
||||
legendtitlefontvalign = :bottom,
|
||||
legendtitlefontrotation = -5.2,
|
||||
legendtitlefontcolor = :blue,
|
||||
background_color_legend = :cyan,
|
||||
foreground_color_legend = :green,
|
||||
)
|
||||
@test p[1][:legend_font_family] == "serif"
|
||||
@test p[1][:legend_font_pointsize] == 12
|
||||
@test p[1][:legend_font_halign] == :left
|
||||
@test p[1][:legend_font_valign] == :top
|
||||
@test p[1][:legend_font_rotation] == 1.0
|
||||
@test p[1][:legend_font_color] == :red
|
||||
@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
|
||||
@test p[1][:legend_title_font_valign] == :bottom
|
||||
@test p[1][:legend_title_font_rotation] == -5.2
|
||||
@test p[1][:legend_title_font_color] == :blue
|
||||
@test p[1][:legend_background_color] == RGBA{Float64}(0.0,1.0,1.0,1.0)
|
||||
@test p[1][:legend_foreground_color] == RGBA{Float64}(0.0,0.5019607843137255,0.0,1.0)
|
||||
end # testset
|
||||
|
||||
Reference in New Issue
Block a user