Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 23, 2025

The edgecolor parameter was being ignored for scatter plots when using single-row DataFrame data combined with the alpha parameter. This resulted in unexpected black edges appearing instead of the specified edge color.

Problem

import pandas as pd
import ultraplot as pplt

d = pd.DataFrame(dict(x=[1, 2], y=[1, 2], sizes=[300, 300]))
fig, ax = pplt.subplots(ncols=3)

# Works correctly - multiple rows with alpha
ax[0].scatter("x", "y", s="sizes", data=d, fc="red8", ec="none", alpha=1)

# BUG - single row with alpha shows black edges instead of no edges  
ax[1].scatter("x", "y", s="sizes", data=d.loc[[1]], fc="red8", ec="none", alpha=1)

# Works correctly - single row without alpha
ax[2].scatter("x", "y", s="sizes", data=d.loc[[1]], fc="red8", ec="none")

Root Cause

The issue was in the _from_data function in ultraplot/internals/inputs.py. This function processes DataFrame column lookups but was incorrectly converting scalar string values like "none" to lists ["none"] even when the string was not found in the DataFrame.

When matplotlib receives:

  • edgecolors='none' → correctly renders no edges
  • edgecolors=['none'] → treats it as a color array, causing inconsistent behavior

Solution

Modified _from_data to preserve scalar values when they are not found in the DataFrame columns. The fix:

  1. Tracks whether any arguments were actually found in the DataFrame
  2. Returns the original scalar value for single-argument cases where no DataFrame lookup occurred
  3. Maintains all existing behavior for multi-argument cases and successful DataFrame lookups

Testing

  • Added regression test test_scatter_edgecolor_single_row to prevent future issues
  • Verified no regressions in existing scatter plot functionality
  • Confirmed other plot types remain unaffected

Fixes #324.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 23, 2025

@cvanelteren 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI and others added 2 commits August 23, 2025 23:06
…function

Co-authored-by: cvanelteren <19485143+cvanelteren@users.noreply.github.com>
Co-authored-by: cvanelteren <19485143+cvanelteren@users.noreply.github.com>
Copilot AI changed the title [WIP] Edgecolor not set on scatter Fix edgecolor not set on scatter plots with single-row DataFrame data Aug 23, 2025
Copilot AI requested a review from cvanelteren August 23, 2025 23:11
@cvanelteren
Copy link
Collaborator

@copilot the test needs to be marked with `pytest.mark.mpl_image_compare

@cvanelteren
Copy link
Collaborator

@copilot ensure the code is formatted with black

…_single_row

Co-authored-by: cvanelteren <19485143+cvanelteren@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot the test needs to be marked with `pytest.mark.mpl_image_compare

Added the @pytest.mark.mpl_image_compare decorator to the test. The test is now properly marked for matplotlib image comparison. (commit 81eb708)

Co-authored-by: cvanelteren <19485143+cvanelteren@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot ensure the code is formatted with black

Applied black formatting to both modified files for consistency with the project style guidelines. (commit 5edfe47)

@codecov
Copy link

codecov bot commented Aug 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cvanelteren
Copy link
Collaborator

@copilot can you fix the title alignment in another PR?

Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot can you fix the title alignment in another PR?

I'd be happy to help with title alignment issues. Could you provide more details about:

  1. Which specific titles need alignment fixes (plot titles, axis titles, legend titles, etc.)?
  2. Where in the codebase or which examples show the alignment problem?
  3. What the expected alignment behavior should be?

Once I understand the specific issue, I can create a separate PR to address it.

@cvanelteren
Copy link
Collaborator

@copilot the original author of the issue stated that the alignment is not working for suptitle, see the description of the original issue above.

Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot the original author of the issue stated that the alignment is not working for suptitle, see the description of the original issue above.

I don't see any mention of suptitle alignment issues in the problem statement provided above. The current issue description only covers the edgecolor problem with scatter plots. Could you provide more details about the suptitle alignment issue, or point me to where it's described? I'd be happy to create a separate PR to fix suptitle alignment once I understand the specific problem.

@cvanelteren
Copy link
Collaborator

@copilot read #324 at the bottom of the issue

Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot read #324 at the bottom of the issue

I can see the suptitle alignment issue now! The problem is in the _align_super_title method which forcefully sets ha="center", overriding any custom horizontal alignment passed via suptitle_kw. I'll create a separate PR to fix this.

@cvanelteren cvanelteren marked this pull request as ready for review August 24, 2025 08:28
@cvanelteren cvanelteren merged commit f2b2b2e into main Aug 24, 2025
28 checks passed
@cvanelteren cvanelteren deleted the copilot/fix-324 branch August 24, 2025 08:28
Copilot AI requested a review from cvanelteren August 24, 2025 08:34
@cvanelteren
Copy link
Collaborator

@copilot you did not do the last task please do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edgecolor not set on scatter

2 participants