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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:08:23+00:00 2026-06-04T19:08:23+00:00

I am using Python and a CSV file. I am currently trying to modify

  • 0

I am using Python and a CSV file. I am currently trying to modify the scatter plot(2d) below to change colors based on a third column in my csv file. After searching through multiple posts, I basically want to use a generic colormap (rainbow) and multiply my third array by the colormap in order to display different colors for each of the xy points. I think I can do everything from the ax.scatter function but I am not sure how to multiply each different x,y coordinate by the colormap and the third array number. It should look similar to a contour plot, but I would prefer a different colored scatter plot.

Here is the code I am using:

import matplotlib   
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas    
from matplotlib.figure import Figure
import matplotlib.mlab as mlab
import numpy as np

r = mlab.csv2rec('test.csv')
fig = Figure(figsize=(6,6))
canvas = FigureCanvas(fig)

ax = fig.add_subplot(111)
ax.set_title("X vs Y AVG",fontsize=14)
ax.set_xlabel("XAVG",fontsize=12)
ax.set_ylabel("YAVG",fontsize=12)
ax.grid(True,linestyle='-',color='0.75')

x = r.xavg #first column
y = r.yavg #second column
z = r.wtr #third column

ax.scatter(x,y,s=.2,c='b', marker = ',', cmap = ?);
  • 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-04T19:08:25+00:00Added an answer on June 4, 2026 at 7:08 pm

    check out the scatter line

    import matplotlib.pyplot as plt
    from matplotlib  import cm
    import numpy as np
    
    fig = plt.figure(figsize=(6,6))
    ax = fig.add_subplot(111)
    ax.set_title("X vs Y AVG",fontsize=14)
    ax.set_xlabel("XAVG",fontsize=12)
    ax.set_ylabel("YAVG",fontsize=12)
    ax.grid(True,linestyle='-',color='0.75')
    x = np.random.random(30)
    y = np.random.random(30)
    z = np.random.random(30)
    
    # scatter with colormap mapping to z value
    ax.scatter(x,y,s=20,c=z, marker = 'o', cmap = cm.jet );
    
    plt.show()
    

    and it produces

    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 am trying to create a csv file using python that is truly Excel-compatible
I am trying to write to a .tsv file using python's CSV module, this
I'm trying to convert the output of vmstat into a CSV file using Python,
I'm trying to parse a CSV file using Python's csv module (specifically, the DictReader
I am using the csv python package to read a csv file like this:
I need to write into a csv file using python and each iterator item
I'm using Python 3. I've written two programs. One loops through a csv file
Using Python I am trying to analyze a tab delimited file. I open the
Using Python to append CSV file, I get data every other row. How do
I am using python's CSV module to iterate over the rows of a column.

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.