Skip to content

Commit 3b613fc

Browse files
authored
Merge pull request #4038 from AaronStiff/3984-facets-empty-dataset
added: ignore facet args with empty dataset
2 parents e6e70fd + 649d275 commit 3b613fc

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66

77
### Fixed
88
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
9+
- Empty pandas dataframe with facet row/column set no longer fails [[#4038](https://github.com/plotly/plotly.py/pull/4038)]
910
- 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)]
1011
- Sanitize JSON output to prevent an XSS vector when graphs are inserted directly into HTML [[#4196](https://github.com/plotly/plotly.py/pull/4196)]
1112
- 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 for: packages/python/plotly/plotly/express/_core.py

+4
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,10 @@ def infer_config(args, constructor, trace_patch, layout_patch):
18801880
args[position] = args["marginal"]
18811881
args[other_position] = None
18821882

1883+
# Ignore facet rows and columns when data frame is empty so as to prevent nrows/ncols equaling 0
1884+
if len(args["data_frame"]) == 0:
1885+
args["facet_row"] = args["facet_col"] = None
1886+
18831887
# If both marginals and faceting are specified, faceting wins
18841888
if args.get("facet_col") is not None and args.get("marginal_y") is not None:
18851889
args["marginal_y"] = None

Diff for: test/percy/plotly-express.py

+3
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,6 @@
543543
)
544544
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color="Task")
545545
fig.write_html(os.path.join(dir_name, "timeline.html"), auto_play=False)
546+
547+
548+
px.bar(pd.DataFrame(columns=["A", "B", "X"]), x="A", y="X", facet_col="B")

0 commit comments

Comments
 (0)