Merge pull request #3302 from sethaxen/hexbinextrakws

Support extra_kwargs in hexbins for PyPlot
This commit is contained in:
Daniel Schwabeneder 2021-02-16 20:46:24 +01:00 committed by GitHub
commit 57e98ac12d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -372,8 +372,10 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
vmin, vmax = clims = get_clims(sp, series) vmin, vmax = clims = get_clims(sp, series)
# Dict to store extra kwargs # Dict to store extra kwargs
if st == :wireframe if st == :wireframe || st == :hexbin
extrakw = KW() # vmin, vmax cause an error for wireframe plot # vmin, vmax cause an error for wireframe plot
# We are not supporting clims for hexbin as calculation of bins is not trivial
extrakw = KW()
else else
extrakw = KW(:vmin => vmin, :vmax => vmax) extrakw = KW(:vmin => vmin, :vmax => vmax)
end end
@ -508,16 +510,17 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
end end
if st == :hexbin if st == :hexbin
handle = ax."hexbin"(x, y, extrakw[:mincnt] = get(series[:extra_kwargs], :mincnt, nothing)
extrakw[:edgecolors] = get(series[:extra_kwargs], :edgecolors, py_color(get_linecolor(series)))
handle = ax."hexbin"(x, y;
label = series[:label], label = series[:label],
C = series[:weights], C = series[:weights],
gridsize = series[:bins]==:auto ? 100 : series[:bins], # 100 is the default value gridsize = series[:bins]==:auto ? 100 : series[:bins], # 100 is the default value
linewidths = py_thickness_scale(plt, series[:linewidth]), linewidths = py_thickness_scale(plt, series[:linewidth]),
edgecolors = py_color(get_linecolor(series)),
alpha = series[:fillalpha], alpha = series[:fillalpha],
cmap = py_fillcolormap(series), # applies to the pcolorfast object cmap = py_fillcolormap(series), # applies to the pcolorfast object
zorder = series[:series_plotindex], zorder = series[:series_plotindex],
# extrakw... # We are not supporting clims for hexbin as calculation of bins is not trivial extrakw...
) )
push!(handles, handle) push!(handles, handle)
end end