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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:15:48+00:00 2026-06-15T02:15:48+00:00

I have a 2D numpy array that’s created like this: data = np.empty((number_of_elements, 7))

  • 0

I have a 2D numpy array that’s created like this:

data = np.empty((number_of_elements, 7))

Each row with 7 (or whatever) floats represents an object’s properties. The first two for example are the x and y position of the object, the others are various properties that could even be used to apply color information to the plot.

I want to do a scatter plot from data, so that if p = data[i], an object is plotted as a point with p[:2] as its 2D position and with say p[2:4] as a color information (the length of that vector should determine a color for the point). Other columns should not matter to the plot at all.

How should I go about this?

  • 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-15T02:15:49+00:00Added an answer on June 15, 2026 at 2:15 am

    Setting up a basic matplotlib figure is easy:

    import matplotlib.pyplot as plt
    import numpy as np
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    

    Picking off the columns for x, y and color might look something like this:

    N = 100
    data = np.random.random((N, 7))
    x = data[:,0]
    y = data[:,1]
    points = data[:,2:4]
    # color is the length of each vector in `points`
    color = np.sqrt((points**2).sum(axis = 1))/np.sqrt(2.0)
    rgb = plt.get_cmap('jet')(color)
    

    The last line retrieves the jet colormap and maps each of the float values (between 0 and 1) in the array color to a 3-tuple RGB value.
    There is a list of colormaps to choose from here. There is also a way to define custom colormaps.

    Making a scatter plot is now straight-forward:

    ax.scatter(x, y, color = rgb)
    plt.show()
    # plt.savefig('/tmp/out.png')    # to save the figure to a file
    

    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 a 2-dimensional numpy array that looks like this: [[a b c] [d
I have a numpy array that contains some image data. I would like to
I have a numpy array like this: x = np.array([[1,2,3],[4,5,6],[7,8,9]]) I need to create
I have a numpy array like this a = np.array(1) Now if I want
I have a Numpy array that looks like >>> a array([[ 3. , 2.
I have a numpy array that I would like to share between a bunch
I have some python code which generates a 256^3 numpy array of data that
I have a numpy array data that just contains a set of integer counts.
I have a numpy array of pixel data that I want to draw at
Okay if you would like to know how this numpy array is created look

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.