JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
437 stars 88 forks source link

Warning when using boxplot(x) #470

Closed arthur-fyon closed 2 years ago

arthur-fyon commented 2 years ago

Since I installed Julia 1.7.0, I get the following warning while simply calling boxplot as before using the GR backend

┌ Warning: Keyword argument hover not supported with Plots.GRBackend(). Choose from: Set([:top_margin, :group, :inset_subplots, :background_color, :ytickfontsize, :yforeground_color_text, :yguidefontcolor, :tickfontfamily, :show_empty_bins, :seriesalpha, :seriescolor, :ztick_direction, :xgrid, :ygridalpha, :zlims, :xtick_direction, :colorbar, :legend_font_family, :zflip, :ticks, :linealpha, :overwrite_figure, :arrow, :xguidefonthalign, :normalize, :linestyle, :xtickfontvalign, :xflip, :zgrid, :fillcolor, :ygrid, :bar_width, :colorbar_scale, :background_color_inside, :zguidefonthalign, :bins, :zguide, :zforeground_color_text, :legend_font_valign, :yscale, :legend_font_color, :weights, :xgridalpha, :ygridstyle, :clims, :xtickfontcolor, :fill_z, :xguide, :markershape, :background_color_subplot, :ztickfontfamily, :fillalpha, :markerstrokewidth, :tick_direction, :xguidefontvalign, :xguidefontfamily, :gridlinewidth, :foreground_color_subplot, :xgridlinewidth, :yguidefontsize, :foreground_color, :foreground_color_text, :titlefonthalign, :yerror, :x, :xtickfonthalign, :zgridlinewidth, :ytickfontrotation, :discrete_values, :ytick_direction, :grid, :xguidefontrotation, :ribbon, :xguidefontsize, :tickfontrotation, :xforeground_color_axis, :xdiscrete_values, :background_color_outside, :titlefontcolor, :xgridstyle, :line_z, :size, :orientation, :gridstyle, :projection, :markersize, :legend_foreground_color, :camera, :zguidefontrotation, :ydiscrete_values, :xforeground_color_grid, :seriestype, :yflip, :quiver, :zticks, :markerstrokecolor, :ztickfontrotation, :ztickfonthalign, :fillrange, :ztickfontvalign, :xlims, :xforeground_color_border, :markercolor, :xtickfontsize, :ylink, :levels, :color_palette, :connections, :yforeground_color_grid, :lims, :zgridstyle, :foreground_color_border, :zguidefontvalign, :xscale, :marker_z, :markerstrokealpha, :left_margin, :markeralpha, :legend_font_halign, :annotations, :window_title, :tickfontvalign, :foreground_color_axis, :zguidefontcolor, :ygridlinewidth, :zlink, :zscale, :smooth, :yguidefontrotation, :xticks, :guidefontsize, :zguidefontsize, :y, :margin, :ytickfontcolor, :zdiscrete_values, :tickfonthalign, :bottom_margin, :yforeground_color_border, :zguidefontfamily, :framestyle, :yguidefontvalign, :yguidefonthalign, :zerror, :zgridalpha, :ztickfontcolor, :scale, :legend_position, :linecolor, :html_output_format, :legend_title, :zforeground_color_border, :legend_font_pointsize, :title, :tickfontcolor, :subplot_index, :flip, :titlefontrotation, :legend_background_color, :tickfontsize, :titlefontvalign, :z, :yforeground_color_axis, :foreground_color_grid, :xtickfontrotation, :linewidth, :ztickfontsize, :gridalpha, :xerror, :guidefontfamily, :ylims, :contour_labels, :xguidefontcolor, :primary, :xtickfontfamily, :ytickfontvalign, :guidefonthalign, :ytickfontfamily, :aspect_ratio, :xforeground_color_text, :show, :link, :colorbar_title, :guidefontrotation, :subplot, :label, :ytickfonthalign, :guide, :guidefontcolor, :yguide, :titlefontsize, :titlefontfamily, :guidefontvalign, :zforeground_color_axis, :zforeground_color_grid, :layout, :legend_font_rotation, :colorbar_entry, :yguidefontfamily, :polar, :right_margin, :xlink, :series_annotations, :yticks]) └ @ Plots C:\Users\arthu\.julia\packages\Plots\AJMX6\src\args.jl:1607

However, the boxplot appears fine as with Julia 1.6.X. If I exectue a second time, the warning does not show again. It seems that this warning should not be there, since the boxplot is fine. Note that simply executing

using StatsPlots; x = rand(20); boxplot(x)

make the warning appears once.

Thanks in advance.

sethaxen commented 2 years ago

I just checked, and in a fresh environment, this happens on v1.6.4 as well. I don't think this is a problem. Only plotly supports the hover attribute, and it's been used here for a long time. I'm guessing Plots recently changed its warning policy, which is why you're seeing the warning now.

sethaxen commented 2 years ago

@mkborregaard @BeastyBlacksmith is there something we can do here so that this warning isn't thrown for every backend but Plotly? In the REPL it's harmless, but in notebooks (e.g. see at 1:00 in the video in https://github.com/fonsp/Pluto.jl/issues/1870#issue-1118326408), it looks pretty bad.

BeastyBlacksmith commented 2 years ago

I think the easiest would be to only add the hover entries in the recipe if the backend is plotly or plotlyjs. Or check if hover is in the supported attributes of the backend.

sethaxen commented 2 years ago

Or check if hover is in the supported attributes of the backend.

How can we access the backend within a recipe, and how can we access the supported attributes?

BeastyBlacksmith commented 2 years ago
Plots.is_attr_supported(backend(), [:hover])