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 9229587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:36:32+00:00 2026-06-18T05:36:32+00:00

I create a bunch of RegularPolygons with this constructor – node.brushShape = RegularPolygon((node.posX, node.posY),

  • 0

I create a bunch of RegularPolygons with this constructor –

        node.brushShape = RegularPolygon((node.posX, node.posY),
                            6,
                            node.radius * 0.8,
                            linewidth = 3,
                            edgecolor = (1,1,1),
                            facecolor = 'none',
                            zorder = brushz)

As you can see, I want the edges of these patches to be white. I put them all into a list called brushShapes and then create a PatchCollection –

self.brushShapesPC = PatchCollection(self.brushShapes, match_original=True)

This way works just fine with keeping the edges white. However, now I want to use a user-defined colormap –

colormap = {'red':  ((0.0, 0.0, 0.0),
               (0.25,0.0, 0.0),
               (0.5, 0.8, 1.0),
               (0.75,1.0, 1.0),
               (1.0, 0.4, 1.0)),

        'green': ((0.0, 0.0, 0.0),
               (0.25,0.0, 0.0),
               (0.5, 0.9, 0.9),
               (0.75,0.0, 0.0),
               (1.0, 0.0, 0.0)),

        'blue':  ((0.0, 0.0, 0.4),
               (0.25,1.0, 1.0),
               (0.5, 1.0, 0.8),
               (0.75,0.0, 0.0),
               (1.0, 0.0, 0.0))} 

So now my PatchCollection instantiation is –

self.brushShapesPC = PatchCollection(self.brushShapes, cmap=mpl.colors.LinearSegmentedColormap('SOMcolormap', self.colormap))

But now the edges have the same color as the face! So what I need to do is – determine what the value would be for white with the new colormap..and change the

edgecolor = (1,1,1)

to

edgecolor = (whatever_white_is)

in this constructor –

node.brushShape = RegularPolygon((node.posX, node.posY),
                        6,
                        node.radius * 0.8,
                        linewidth = 3,
                        edgecolor = (1,1,1),
                        facecolor = 'none',
                        zorder = brushz)

is that right? I have gotten very stuck trying to determine what the value for white would be. When I bring up a colorbar, it shows white being right in the center…so I’ve tried (0.5, 0.5, 0.5), (0,1,0), etc. Can anyone help me figure out what I should put? Is there a generic way to know what white is for any given colormap?

  • 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-18T05:36:33+00:00Added an answer on June 18, 2026 at 5:36 am

    I think you’re going about this a bit backwards. There’s no completely generic way to determine what white would be in a colormap (it may exist more than once or not at all).

    However, you can just specify that the edges of the polygons should be white when using a PolyCollection while still using the colormap for the faces. Just specify edgecolors instead of edgecolor. It’s a touch confusing, but the idea is that it’s plural, as you could have multiple values specified. Also, have a look at RegularPolygonCollection

    As a quick example:

    import matplotlib.pyplot as plt
    from matplotlib.patches import RegularPolygon
    from matplotlib.collections import PatchCollection
    import numpy as np
    
    xy = np.random.random((10,2))
    z = np.random.random(10)
    
    patches = [RegularPolygon((x,y), 5, 0.1) for x, y in xy]
    collection = PatchCollection(patches, array=z, edgecolors='white', lw=2)
    
    fig, ax = plt.subplots()
    # So that the white edges show up...
    ax.patch.set(facecolor='black')
    ax.add_collection(collection)
    ax.autoscale()
    
    plt.show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to create a bunch of methods that look like this. The things
I am trying to create a bunch of variables like this: function l(){ var
Im usign this to create a bunch on draggable elements: $$('.box').each( function(item){ new Draggable(item)
Twice this month, I've had to create a total a bunch of records of
I have create a bunch of .o files (via gcc -c $file.c $someotherops -o
I want to create a bunch of errors. each specific to its own class
If you create a bunch of heatmaps: for i=1:10 HeatMap(rand(5,5)) end then you're left
I want to create a helper screen that can create a bunch of Django
I have a C# WPF application where I need to create a bunch of
I have used the Java Wireless Toolkit Stub Generator to create a bunch of

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.