Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:31:36+00:00 2026-06-09T09:31:36+00:00

if I have a scatter plot in matplotlib that returns a CircleCollection: coll =

  • 0

if I have a scatter plot in matplotlib that returns a CircleCollection:

coll = plt.scatter(rand(5), rand(5), c="k")

how can I reset the colors of just specific points? I notice that coll is not iterable. I want to just alter the face/edge colors of already plotted points, although they already have a color set from the initial plt.scatter call. How can this be done?

For example: just change the color of the second point plotted, e.g.:

coll[1].set_color("r") # this does not work, coll not indexable this way

I know I can pass a vector of colors to c= in scatter but I’d like to intentionally reset the points later, since the colors are not known for all the points at the time when plt.scatter is initially called.

edit: further explanation. I am looking for the simplest way to color points in a scatter based on different conditions. if points is a two-d array and you plot it with scatter(points[:, 0], points[:, 1], c-"k"), it’s convenient to later on based on certain conditions, e.g.

# replot certain points in red with alpha
selected = points[:, 0] > 0.5
plt.scatter(selected[:, 0], selected[:, 1], c="r", alpha=0.5)

here I replot over the old points but this is messy since the new points are plotted with an alpha, so it will not give the desired effect. The various conditions according to which points have to be re-colored might be complex and happen later than when the initial scatter is made, so it’s convenient to just be able to change the color of an existing point, rather than split the points up based on conditions and plot them all separately.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:31:38+00:00Added an answer on June 9, 2026 at 9:31 am

    This works for me. Probably you need to call plt.draw before (or instead of) fig.show.

    coll = plt.scatter(rand(5), rand(5), c="k")
    fig = plt.gcf()
    fig.show()  # or fig.savefig("a.png")
    
    coll.set_color(['b', 'g', 'r', 'y', 'k'])
    fig.show()  # or fig.savefig("b.png")
    

    Updated

    This is how to partially modify colors. You need to extend colors array explicitly if you use the single color when calling scatter.

    num = 5
    coll = plt.scatter(rand(num), rand(num), c='k')
    # coll = plt.scatter(rand(num), rand(num), c=['b', 'g', 'r', 'y', 'k'])
    fig = plt.gcf()
    fig.show()
    
    colors = coll.get_facecolor()
    if colors.shape[0] == 1:
        newcolors = np.tile(colors, (num, 1))
    else:
        newcolors = colors
    newcolors[0] = [0, 0.75, 0.75, 1]
    coll.set_color(newcolors)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if I make a scatter plot with matplotlib: plt.scatter(randn(100),randn(100)) # set x, y lims
I have a scatter plot in R (with ggplot2). The data has a numeric
This should be easy but I have just started toying with matplotlib and python.
I have a scatter plot with 10 points, some points are above and below
I have a matplotlib figure that I want to be able to switch between
i have a scatter plot graph i would like each dot to have a
I have thousands of points to Plot on a JFreeChart scatter plot. The problem
I'm trying to generate a linear regression on a scatter plot I have generated,
Scatter Plots in MatLab. I can create a scatter plot with x and y
I have this bit of code that plots out the points: import matplotlib.pyplot as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.