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

  • Home
  • SEARCH
  • 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 8121701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:34:44+00:00 2026-06-06T05:34:44+00:00

I want to generate a bar graph from from a csv file my data

  • 0

I want to generate a bar graph from from a csv file my data looks like this:

06/14/12    SMB 12104560    8096373.6   1.5     1.08
06/15/12    SMB 10328540    8217192.68  1.26    1.24
06/18/12    SMB 5495294     8232792.78  0.67    0.85

I want the first column to be the x-axis and the last column to be the y-axis, Also if possible I just want to use the last 5 rows of data. This is what I have tried so far but
Thanks

Edit New code:

data = numpy.loadtxt(StringIO(etf + '.csv' ,dtype= [("date", "S8"), ("value", "f8")]) , usecols=(0,-1))
x = numpy.arange(len(data))
pl1.bar(x,data["value"], width = 0.8)
p1.xticks(x+.4, data["date"])
p1.show()

new error: TypeError: __init__() got an unexpected keyword argument 'dtype'

  • 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-06T05:34:47+00:00Added an answer on June 6, 2026 at 5:34 am
    import numpy as np
    from StringIO import StringIO
    import pylab as pl
    
    datastr = """06/14/12    SMB 12104560    8096373.6   1.5     1.08
    06/15/12    SMB 10328540    8217192.68  1.26    1.24
    06/18/12    SMB 5495294     8232792.78  0.67    0.85"""
    
    data = np.loadtxt(StringIO(datastr), 
                      dtype=np.dtype([("date", "S8"), ("value", "f8")]), 
                      usecols=(0,-1))
    x = np.arange(len(data))
    pl.bar(x, data["value"], width=0.8)
    pl.xticks(x+0.4, data["date"])
    pl.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 want to generate an MS Excel file from PHP. I know one can
I want to put for each bar from barchart a label to generate a
I want to auto-generate a HTML table from some custom data. One of the
From this XML source : <?xml version=1.0 encoding=utf-8 ?> <ROOT> <STRUCT> <COL order=1 nodeName=FOO/BAR
Sometimes I want to generate INSERT statements from the contents of a database table.
In my JSF/Facelets application, I want to dynamically generate a breadcrumb trail from a
What I want to do: I am trying to generate an XSD file for
I'm trying to convert from HTML to Latex, and want to change this: <a
I have a makefile, with two variables like this OS = foo.o bar.o baz.o
I have one schema file that I'm using to generate java files. I want

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.