diff --git a/CHANGELOG.md b/CHANGELOG.md index 454d2210ab4..37e61a25bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)] + - Empty pandas dataframe with facet row/column set no longer fails [[#4038](https://github.com/plotly/plotly.py/pull/4038)] - Added some rounding to the `make_subplots` function to handle situations where the user-input specs cause the domain to exceed 1 by small amounts [[#4153](https://github.com/plotly/plotly.py/pull/4153)] - Sanitize JSON output to prevent an XSS vector when graphs are inserted directly into HTML [[#4196](https://github.com/plotly/plotly.py/pull/4196)] - Fixed issue with shapes and annotations plotting on the wrong y axis when supplied with a specific axis in the `yref` parameter [[#4177](https://github.com/plotly/plotly.py/pull/4177)] diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 76ab33c90fa..c9f03580faf 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1880,6 +1880,10 @@ def infer_config(args, constructor, trace_patch, layout_patch): args[position] = args["marginal"] args[other_position] = None + # Ignore facet rows and columns when data frame is empty so as to prevent nrows/ncols equaling 0 + if len(args["data_frame"]) == 0: + args["facet_row"] = args["facet_col"] = None + # If both marginals and faceting are specified, faceting wins if args.get("facet_col") is not None and args.get("marginal_y") is not None: args["marginal_y"] = None diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 85bd910712d..49d3fdb8249 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -543,3 +543,6 @@ ) fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color="Task") fig.write_html(os.path.join(dir_name, "timeline.html"), auto_play=False) + + +px.bar(pd.DataFrame(columns=["A", "B", "X"]), x="A", y="X", facet_col="B")