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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:24:24+00:00 2026-06-12T19:24:24+00:00

I am using the class matplotlib.patches.Polygon to draw polygons on a map. In fact,

  • 0

I am using the class matplotlib.patches.Polygon to draw polygons on a map. In fact, the information about the coordinates of the corners of the polygons and a floating point data value for each “polygon” are given.
Now I’d like to convert these data values (ranging from 0 to 3e15) into color information to visualize it nicely. What is the best practice for doing that in Python?

A snippet of my code:

poly = Polygon( xy, facecolor=data, edgecolor='none')
plt.gca().add_patch(poly)
  • 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-12T19:24:25+00:00Added an answer on June 12, 2026 at 7:24 pm

    In the RGB color system two bits of data are used for each color, red, green, and blue. That means that each color runs on a scale from 0 to 255. Black would be 00,00,00, while white would be 255,255,255. Matplotlib has lots of pre-defined colormaps for you to use. They are all normalized to 255, so they run from 0 to 1. So you need only normalize your data, then you can manually select colors from a color map as follows:

    >>> import matplotlib.pyplot as plt
    
    >>> Blues = plt.get_cmap('Blues')
    >>> print Blues(0)
    (0.9686274528503418, 0.9843137264251709, 1.0, 1.0)
    >>> print Blues(0.5)
    (0.41708574119736169, 0.68063054575639614, 0.83823145908467911, 1.0)
    >>> print Blues(1.0)
    (0.96555171293370867, 0.9823452528785257, 0.9990157632266774, 1.0)
    

    Here are all of the predefined colormaps. If you’re interested in creating your own color maps, here is a good example. Also here is a paper from IBM on choosing colors carefully, something you should be considering if you’re using color to visualize data.

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

Sidebar

Related Questions

Language: PHP / Using Class Upload by Colin Verot About: Multiple Uploading The code
I using class Overlay to marker place on map.. I want show infomation of
I'm thinking about using class (singleton) with collections implemented using ConcurrentDictionary. This class will
I'm thinking about using custom attributes in Jquery to avoid using class or id
I have this program to draw a labelled edge with the nodes using matplotlib
I know others have asked about using class and id in CSS files, such
Anyone can point out a documentation or a detailed discussion using @class. I've been
Using class name I am firing a click event in jquery. Class names are
I'm using Class based generic views, can anybody suggest me how can i set
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();

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.