(args, constructor, trace_patch, layout_patch)
| 2207 | |
| 2208 | |
| 2209 | def infer_config(args, constructor, trace_patch, layout_patch): |
| 2210 | attrs = [k for k in direct_attrables + array_attrables if k in args] |
| 2211 | grouped_attrs = [] |
| 2212 | df: nw.DataFrame = args["data_frame"] |
| 2213 | |
| 2214 | # Compute sizeref |
| 2215 | sizeref = 0 |
| 2216 | if "size" in args and args["size"]: |
| 2217 | sizeref = ( |
| 2218 | nw.to_py_scalar(df.get_column(args["size"]).max()) / args["size_max"] ** 2 |
| 2219 | ) |
| 2220 | |
| 2221 | # Compute color attributes and grouping attributes |
| 2222 | if "color" in args: |
| 2223 | if "color_continuous_scale" in args: |
| 2224 | if "color_discrete_sequence" not in args: |
| 2225 | attrs.append("color") |
| 2226 | else: |
| 2227 | if args["color"] and _is_continuous(df, args["color"]): |
| 2228 | attrs.append("color") |
| 2229 | args["color_is_continuous"] = True |
| 2230 | elif constructor in [go.Sunburst, go.Treemap, go.Icicle]: |
| 2231 | attrs.append("color") |
| 2232 | args["color_is_continuous"] = False |
| 2233 | else: |
| 2234 | grouped_attrs.append("marker.color") |
| 2235 | elif "line_group" in args or constructor == go.Histogram2dContour: |
| 2236 | grouped_attrs.append("line.color") |
| 2237 | elif constructor in [go.Pie, go.Funnelarea]: |
| 2238 | attrs.append("color") |
| 2239 | if args["color"]: |
| 2240 | if args["hover_data"] is None: |
| 2241 | args["hover_data"] = [] |
| 2242 | args["hover_data"].append(args["color"]) |
| 2243 | else: |
| 2244 | grouped_attrs.append("marker.color") |
| 2245 | |
| 2246 | show_colorbar = bool( |
| 2247 | "color" in attrs |
| 2248 | and args["color"] |
| 2249 | and constructor not in [go.Pie, go.Funnelarea] |
| 2250 | and ( |
| 2251 | constructor not in [go.Treemap, go.Sunburst, go.Icicle] |
| 2252 | or args.get("color_is_continuous") |
| 2253 | ) |
| 2254 | ) |
| 2255 | else: |
| 2256 | show_colorbar = False |
| 2257 | |
| 2258 | if "line_dash" in args: |
| 2259 | grouped_attrs.append("line.dash") |
| 2260 | |
| 2261 | if "symbol" in args: |
| 2262 | grouped_attrs.append("marker.symbol") |
| 2263 | |
| 2264 | if "pattern_shape" in args: |
| 2265 | if constructor in [go.Scatter]: |
| 2266 | grouped_attrs.append("fillpattern.shape") |
no test coverage detected