Plots.jl/test/test_defaults.jl
Simon Christ 2e67e84361
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 d880d89ef66eb18731bc67d32d627dd690c6d9e5.

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>
2021-10-22 15:09:14 +02:00

71 lines
2.7 KiB
Julia

using Plots, Test, Colors
const PLOTS_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino)
Plots.__init__()
@testset "Loading theme" begin
pl = plot(1:5)
@test pl[1][1][:seriescolor] == RGBA(colorant"black")
@test guidefont(pl[1][:xaxis]).family == "palantino"
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