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
8 changes: 8 additions & 0 deletions ultraplot/internals/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def _from_data(data, *args):
if data is None:
return
args = list(args)
found_in_data = False
for i, arg in enumerate(args):
if isinstance(arg, str):
try:
Expand All @@ -255,6 +256,13 @@ def _from_data(data, *args):
pass
else:
args[i] = array
found_in_data = True

# If only one argument and it wasn't found in data, return the original scalar
# This prevents scalar values like "none" from becoming ["none"]
if len(args) == 1 and not found_in_data:
return args[0]

return args


Expand Down
40 changes: 40 additions & 0 deletions ultraplot/tests/test_1dplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,46 @@ def test_scatter_args(rng):
return fig


@pytest.mark.mpl_image_compare
def test_scatter_edgecolor_single_row():
"""
Test that edgecolor is properly handled for single-row DataFrame input.
This is a regression test for issue #324.
"""
import pandas as pd

# Create test data
df_multi = pd.DataFrame({"x": [1, 2], "y": [1, 2], "sizes": [300, 300]})
df_single = pd.DataFrame({"x": [2], "y": [2], "sizes": [300]})

fig, axs = uplt.subplots(ncols=3, share=0)

# Test multiple rows with alpha
result1 = axs[0].scatter(
"x", "y", s="sizes", data=df_multi, fc="red8", ec="none", alpha=1
)

# Test single row with alpha (the problematic case)
result2 = axs[1].scatter(
"x", "y", s="sizes", data=df_single, fc="red8", ec="none", alpha=1
)

# Test single row without alpha
result3 = axs[2].scatter("x", "y", s="sizes", data=df_single, fc="red8", ec="none")

# Verify that edgecolors are correctly set to no edges for all cases
# An empty array means no edges (which is what 'none' should produce)
assert len(result1.get_edgecolors()) == 0, "Multiple rows should have no edges"
assert (
len(result2.get_edgecolors()) == 0
), "Single row with alpha should have no edges"
assert (
len(result3.get_edgecolors()) == 0
), "Single row without alpha should have no edges"

return fig


@pytest.mark.mpl_image_compare
def test_scatter_inbounds():
"""
Expand Down