Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
and attr_name == "z"
):
# ensure that stuff like "count" gets into the hoverlabel
mapping_labels[attr_label] = "%%{%s}" % attr_name
if attr_label is not None:
mapping_labels[attr_label] = "%%{%s}" % attr_name
if trace_spec.constructor not in [go.Parcoords, go.Parcats]:
# Modify mapping_labels according to hover_data keys
# if hover_data is a dict
Expand Down
10 changes: 10 additions & 0 deletions tests/test_optional/test_px/test_px_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,13 @@ def test_timeline_cols_already_temporal(constructor, datetime_columns):
assert len(fig.data) == 3
assert fig.layout.xaxis.type == "date"
assert fig.layout.xaxis.title.text is None


def test_empty_histogram():
"""Empty px.histogram() should not raise, matching scatter/bar/pie behavior.

Regression test for https://github.com/plotly/plotly.py/issues/5534
"""
fig = px.histogram()
assert len(fig.data) == 1
assert fig.data[0].type == "histogram"