Merge cb3dac22495a64d89a04b7db02d174f9e1c3017f into 2df85eb0fd328a4f876f2d6cb53c0aafdf38a899
This commit is contained in:
commit
69cd97faef
@ -510,7 +510,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
zorder = series[:series_plotindex] + 0.5,
|
zorder = series[:series_plotindex] + 0.5,
|
||||||
marker = py_marker(_cycle(series[:markershape], i)),
|
marker = py_marker(_cycle(series[:markershape], i)),
|
||||||
s = py_thickness_scale(plt, _cycle(series[:markersize], i)).^ 2,
|
s = py_thickness_scale(plt, _cycle(series[:markersize], i)).^ 2,
|
||||||
facecolors = py_color(get_markercolor(series, i), get_markeralpha(series, i)),
|
facecolors = py_color(get_markercolor(series, clims, i, sp[:colorbar_scale]), get_markeralpha(series, i)),
|
||||||
edgecolors = py_color(get_markerstrokecolor(series, i), get_markerstrokealpha(series, i)),
|
edgecolors = py_color(get_markerstrokecolor(series, i), get_markerstrokealpha(series, i)),
|
||||||
linewidths = py_thickness_scale(plt, get_markerstrokewidth(series, i)),
|
linewidths = py_thickness_scale(plt, get_markerstrokewidth(series, i)),
|
||||||
extrakw...
|
extrakw...
|
||||||
@ -691,8 +691,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
path;
|
path;
|
||||||
label = series[:label],
|
label = series[:label],
|
||||||
zorder = series[:series_plotindex],
|
zorder = series[:series_plotindex],
|
||||||
edgecolor = py_color(get_linecolor(series, clims, i), get_linealpha(series, i)),
|
edgecolor = py_color(get_linecolor(series, clims, i, sp[:colorbar_scale]), get_linealpha(series, i)),
|
||||||
facecolor = py_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)),
|
facecolor = py_color(get_fillcolor(series, clims, i, sp[:colorbar_scale]), get_fillalpha(series, i)),
|
||||||
linewidth = py_thickness_scale(plt, get_linewidth(series, i)),
|
linewidth = py_thickness_scale(plt, get_linewidth(series, i)),
|
||||||
linestyle = py_linestyle(st, get_linestyle(series, i)),
|
linestyle = py_linestyle(st, get_linestyle(series, i)),
|
||||||
fill = true
|
fill = true
|
||||||
@ -727,7 +727,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
|
|
||||||
handle = getproperty(ax, f)(args..., trues(n), false, py_fillstepstyle(st);
|
handle = getproperty(ax, f)(args..., trues(n), false, py_fillstepstyle(st);
|
||||||
zorder = series[:series_plotindex],
|
zorder = series[:series_plotindex],
|
||||||
facecolor = py_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)),
|
facecolor = py_color(get_fillcolor(series, clims, i, sp[:colorbar_scale]), get_fillalpha(series, i)),
|
||||||
linewidths = 0
|
linewidths = 0
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
@ -937,7 +937,16 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
kw[:boundaries] = vcat(0, kw[:values] + 0.5)
|
kw[:boundaries] = vcat(0, kw[:values] + 0.5)
|
||||||
elseif any(colorbar_series[attr] !== nothing for attr in (:line_z, :fill_z, :marker_z))
|
elseif any(colorbar_series[attr] !== nothing for attr in (:line_z, :fill_z, :marker_z))
|
||||||
cmin, cmax = get_clims(sp)
|
cmin, cmax = get_clims(sp)
|
||||||
norm = pycolors."Normalize"(vmin = cmin, vmax = cmax)
|
norm = if sp[:colorbar_scale] === :identity
|
||||||
|
pycolors."Normalize"(vmin = cmin, vmax = cmax)
|
||||||
|
elseif sp[:colorbar_scale] === :log10
|
||||||
|
pycolors."LogNorm"(vmin=cmin, vmax=cmax)
|
||||||
|
else
|
||||||
|
@warn("Undefined colorbarscale")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
f = if colorbar_series[:line_z] !== nothing
|
f = if colorbar_series[:line_z] !== nothing
|
||||||
py_linecolormap
|
py_linecolormap
|
||||||
elseif colorbar_series[:fill_z] !== nothing
|
elseif colorbar_series[:fill_z] !== nothing
|
||||||
@ -993,7 +1002,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
cb."set_label"(sp[:colorbar_title],size=py_thickness_scale(plt, sp[:colorbar_titlefontsize]),family=sp[:colorbar_titlefontfamily], color = py_color(sp[:colorbar_titlefontcolor]))
|
cb."set_label"(sp[:colorbar_title],size=py_thickness_scale(plt, sp[:colorbar_titlefontsize]),family=sp[:colorbar_titlefontfamily], color = py_color(sp[:colorbar_titlefontcolor]))
|
||||||
|
|
||||||
# cb."formatter".set_useOffset(false) # This for some reason does not work, must be a pyplot bug, instead this is a workaround:
|
# cb."formatter".set_useOffset(false) # This for some reason does not work, must be a pyplot bug, instead this is a workaround:
|
||||||
cb."formatter".set_powerlimits((-Inf, Inf))
|
sp[:colorbar_scale] === :identity ? cb."formatter".set_powerlimits((-Inf, Inf)) : nothing
|
||||||
cb."update_ticks"()
|
cb."update_ticks"()
|
||||||
|
|
||||||
env = "\\mathregular" # matches the outer fonts https://matplotlib.org/tutorials/text/mathtext.html
|
env = "\\mathregular" # matches the outer fonts https://matplotlib.org/tutorials/text/mathtext.html
|
||||||
@ -1377,8 +1386,8 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
|||||||
push!(handles,
|
push!(handles,
|
||||||
if series[:seriestype] == :shape || series[:fillrange] !== nothing
|
if series[:seriestype] == :shape || series[:fillrange] !== nothing
|
||||||
pypatches."Patch"(
|
pypatches."Patch"(
|
||||||
edgecolor = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
|
edgecolor = py_color(single_color(get_linecolor(series, clims, sp[:colorbar_scale])), get_linealpha(series)),
|
||||||
facecolor = py_color(single_color(get_fillcolor(series, clims)), get_fillalpha(series)),
|
facecolor = py_color(single_color(get_fillcolor(series, clims, sp[:colorbar_scale])), get_fillalpha(series)),
|
||||||
linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)),
|
linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)),
|
||||||
linestyle = py_linestyle(series[:seriestype], get_linestyle(series)),
|
linestyle = py_linestyle(series[:seriestype], get_linestyle(series)),
|
||||||
capstyle = "butt"
|
capstyle = "butt"
|
||||||
@ -1386,7 +1395,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
|||||||
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :stepmid, :steppost)
|
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :stepmid, :steppost)
|
||||||
hasline = get_linewidth(series) > 0
|
hasline = get_linewidth(series) > 0
|
||||||
PyPlot.plt."Line2D"((0, 1),(0,0),
|
PyPlot.plt."Line2D"((0, 1),(0,0),
|
||||||
color = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
|
color = py_color(single_color(get_linecolor(series, clims, sp[:colorbar_scale])), get_linealpha(series)),
|
||||||
linewidth = py_thickness_scale(plt, hasline * sp[:legendfontsize] / 8),
|
linewidth = py_thickness_scale(plt, hasline * sp[:legendfontsize] / 8),
|
||||||
linestyle = py_linestyle(:path, get_linestyle(series)),
|
linestyle = py_linestyle(:path, get_linestyle(series)),
|
||||||
solid_capstyle = "butt", solid_joinstyle = "miter",
|
solid_capstyle = "butt", solid_joinstyle = "miter",
|
||||||
@ -1394,7 +1403,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
|||||||
marker = py_marker(_cycle(series[:markershape], 1)),
|
marker = py_marker(_cycle(series[:markershape], 1)),
|
||||||
markersize = py_thickness_scale(plt, 0.8 * sp[:legendfontsize]),
|
markersize = py_thickness_scale(plt, 0.8 * sp[:legendfontsize]),
|
||||||
markeredgecolor = py_color(single_color(get_markerstrokecolor(series)), get_markerstrokealpha(series)),
|
markeredgecolor = py_color(single_color(get_markerstrokecolor(series)), get_markerstrokealpha(series)),
|
||||||
markerfacecolor = py_color(single_color(get_markercolor(series, clims)), get_markeralpha(series)),
|
markerfacecolor = py_color(single_color(get_markercolor(series, clims, sp[:colorbar_scale])), get_markeralpha(series)),
|
||||||
markeredgewidth = py_thickness_scale(plt, 0.8 * get_markerstrokewidth(series) * sp[:legendfontsize] / first(series[:markersize])) # retain the markersize/markerstroke ratio from the markers on the plot
|
markeredgewidth = py_thickness_scale(plt, 0.8 * get_markerstrokewidth(series) * sp[:legendfontsize] / first(series[:markersize])) # retain the markersize/markerstroke ratio from the markers on the plot
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
|||||||
11
src/utils.jl
11
src/utils.jl
@ -479,17 +479,24 @@ for comp in (:line, :fill, :marker)
|
|||||||
|
|
||||||
@eval begin
|
@eval begin
|
||||||
|
|
||||||
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1)
|
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1, scale::Symbol = :identity)
|
||||||
c = series[$Symbol($compcolor)]
|
c = series[$Symbol($compcolor)]
|
||||||
z = series[$Symbol($comp_z)]
|
z = series[$Symbol($comp_z)]
|
||||||
if z === nothing
|
if z === nothing
|
||||||
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
|
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
|
||||||
else
|
else
|
||||||
get(get_gradient(c), z[i], (cmin, cmax))
|
if scale === :identity
|
||||||
|
return get(get_gradient(c), z[i], (cmin, cmax))
|
||||||
|
elseif scale == :log10
|
||||||
|
return get(get_gradient(c), log10(z[i]), (log10(cmin), log10(cmax)))
|
||||||
|
else
|
||||||
|
@warn("Undefined colorbar scale")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
$get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i)
|
$get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i)
|
||||||
|
$get_compcolor(series, clims, i::Int = 1, scale::Symbol=:identity) = $get_compcolor(series, clims[1], clims[2], i, scale)
|
||||||
|
|
||||||
function $get_compcolor(series, i::Int = 1)
|
function $get_compcolor(series, i::Int = 1)
|
||||||
if series[$Symbol($comp_z)] === nothing
|
if series[$Symbol($comp_z)] === nothing
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user