Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35e96a5302 | |||
| e84905c2a0 | |||
| 1c621feacc | |||
| e8356965e9 | |||
| 72428000cc |
+1
-1
@@ -1,7 +1,7 @@
|
||||
name = "Plots"
|
||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
author = ["Tom Breloff (@tbreloff)"]
|
||||
version = "1.23.0"
|
||||
version = "1.23.2"
|
||||
|
||||
[deps]
|
||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
|
||||
@@ -89,6 +89,8 @@ const _allTypes = vcat(
|
||||
_3dTypes,
|
||||
)
|
||||
|
||||
const _z_colored_series = [:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin]
|
||||
|
||||
const _typeAliases = Dict{Symbol,Symbol}(
|
||||
:n => :none,
|
||||
:no => :none,
|
||||
|
||||
@@ -1627,7 +1627,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
||||
),
|
||||
linewidth = py_thickness_scale(
|
||||
plt,
|
||||
hasline * sp[:legendfontsize] / 8,
|
||||
hasline * sp[:legend_font_pointsize] / 8,
|
||||
),
|
||||
linestyle = py_linestyle(:path, get_linestyle(series)),
|
||||
solid_capstyle = "butt",
|
||||
@@ -1635,7 +1635,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
||||
dash_capstyle = "butt",
|
||||
dash_joinstyle = "miter",
|
||||
marker = py_marker(_cycle(series[:markershape], 1)),
|
||||
markersize = py_thickness_scale(plt, 0.8 * sp[:legendfontsize]),
|
||||
markersize = py_thickness_scale(plt, 0.8 * sp[:legend_font_pointsize]),
|
||||
markeredgecolor = py_color(
|
||||
single_color(get_markerstrokecolor(series)),
|
||||
get_markerstrokealpha(series),
|
||||
@@ -1646,7 +1646,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
||||
),
|
||||
markeredgewidth = py_thickness_scale(
|
||||
plt,
|
||||
0.8 * get_markerstrokewidth(series) * sp[:legendfontsize] /
|
||||
0.8 * get_markerstrokewidth(series) * sp[:legend_font_pointsize] /
|
||||
first(series[:markersize]),
|
||||
), # retain the markersize/markerstroke ratio from the markers on the plot
|
||||
)
|
||||
|
||||
+7
-12
@@ -5,27 +5,24 @@ process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema
|
||||
# don't specialize on ::Function otherwise python functions won't work
|
||||
process_clims(f) = f
|
||||
|
||||
const sp_clims = IdDict{Subplot,Tuple{Float64,Float64}}()
|
||||
const series_clims = IdDict{Series,Tuple{Float64,Float64}}()
|
||||
|
||||
get_clims(sp::Subplot)::Tuple{Float64,Float64} =
|
||||
haskey(sp_clims, sp) ? sp_clims[sp] : update_clims(sp)
|
||||
haskey(sp.attr, :clims_calculated) ? sp[:clims_calculated] : update_clims(sp)
|
||||
get_clims(series::Series)::Tuple{Float64,Float64} =
|
||||
haskey(series_clims, series) ? series_clims[series] : update_clims(series)
|
||||
|
||||
haskey(series.plotattributes, :clims_calculated) ?
|
||||
series[:clims_calculated]::Tuple{Float64,Float64} : update_clims(series)
|
||||
get_clims(sp::Subplot, series::Series)::Tuple{Float64,Float64} =
|
||||
series[:colorbar_entry] ? get_clims(sp) : get_clims(series)
|
||||
|
||||
function update_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64,Float64}
|
||||
zmin, zmax = Inf, -Inf
|
||||
for series in series_list(sp)
|
||||
if series[:colorbar_entry]
|
||||
if series[:colorbar_entry]::Bool
|
||||
zmin, zmax = _update_clims(zmin, zmax, update_clims(series, op)...)
|
||||
else
|
||||
update_clims(series, op)
|
||||
end
|
||||
end
|
||||
return sp_clims[sp] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
return sp[:clims_calculated] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
end
|
||||
|
||||
"""
|
||||
@@ -36,10 +33,9 @@ values of the input. The value is stored as a series property, which is retrieve
|
||||
"""
|
||||
function update_clims(series::Series, op = ignorenan_extrema)::Tuple{Float64,Float64}
|
||||
zmin, zmax = Inf, -Inf
|
||||
z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin)
|
||||
|
||||
# keeping this unrolled has higher performance
|
||||
if series[:seriestype] ∈ z_colored_series && series[:z] !== nothing
|
||||
if series[:seriestype] ∈ _z_colored_series && series[:z] !== nothing
|
||||
zmin, zmax = update_clims(zmin, zmax, series[:z], op)
|
||||
end
|
||||
if series[:line_z] !== nothing
|
||||
@@ -51,8 +47,7 @@ function update_clims(series::Series, op = ignorenan_extrema)::Tuple{Float64,Flo
|
||||
if series[:fill_z] !== nothing
|
||||
zmin, zmax = update_clims(zmin, zmax, series[:fill_z], op)
|
||||
end
|
||||
|
||||
return series_clims[series] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
return series[:clims_calculated] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
end
|
||||
|
||||
update_clims(zmin, zmax, vals::AbstractSurface, op)::Tuple{Float64,Float64} =
|
||||
|
||||
+7
-17
@@ -8,24 +8,14 @@ function RecipesPipeline.warn_on_recipe_aliases!(
|
||||
recipe_type::Symbol,
|
||||
@nospecialize(args)
|
||||
)
|
||||
for k in keys(plotattributes)
|
||||
if !is_default_attribute(k)
|
||||
dk = get(_keyAliases, k, k)
|
||||
if k !== dk
|
||||
if recipe_type == :user
|
||||
signature_string = RecipesPipeline.userrecipe_signature_string(args)
|
||||
elseif recipe_type == :type
|
||||
signature_string = RecipesPipeline.typerecipe_signature_string(args)
|
||||
elseif recipe_type == :plot
|
||||
signature_string = RecipesPipeline.plotrecipe_signature_string(args)
|
||||
elseif recipe_type == :series
|
||||
signature_string = RecipesPipeline.seriesrecipe_signature_string(args)
|
||||
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`."
|
||||
pkeys = keys(plotattributes)
|
||||
for k in pkeys
|
||||
dk = get(_keyAliases, k, nothing)
|
||||
if dk !== nothing
|
||||
kv = RecipesPipeline.pop_kw!(plotattributes, k)
|
||||
if dk ∉ pkeys
|
||||
plotattributes[dk] = kv
|
||||
end
|
||||
plotattributes[dk] = RecipesPipeline.pop_kw!(plotattributes, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
using Plots, Test
|
||||
using OffsetArrays
|
||||
|
||||
@testset "User recipes" begin
|
||||
struct LegendPlot end
|
||||
@recipe function f(plot::LegendPlot)
|
||||
legend --> :topleft
|
||||
(1:3, 1:3)
|
||||
end
|
||||
pl = plot(LegendPlot(); legend = :right)
|
||||
@test pl[1][:legend_position] == :right
|
||||
pl = plot(LegendPlot())
|
||||
@test pl[1][:legend_position] == :topleft
|
||||
end
|
||||
|
||||
@testset "lens!" begin
|
||||
pl = plot(1:5)
|
||||
lens!(pl, [1, 2], [1, 2], inset = (1, bbox(0.0, 0.0, 0.2, 0.2)), colorbar = false)
|
||||
|
||||
Reference in New Issue
Block a user