Hi,

firstly, I do not fully understand why you have chosen such a complicated
solution to a rather simple problem. If the data in your file really is like
the example then you could simply put the file 'ch1.csv' into the same
directory as your Python script.

I have slightly modified it (I don't like the "from" import statements too
much) and commented your lines.

#from matplotlib import mlab

#from pylab import figure, show

#import matplotlib.cbook as cbook

import pylab



#datafile = cbook.get_sample_data('ch1.csv', asfileobj=False)

datafile = 'ch1.csv'

print 'loading', datafile

#a = mlab.csv2rec(datafile)

a = pylab.loadtxt(datafile, comments='#', delimiter=';')

a.sort()

print a.dtype



fig = pylab.figure()

ax = fig.add_subplot(111)

#ax.plot(a.date, a.adj_close, '-')

#fig.autofmt_xdate()

ax.plot(a, 'o')

fig.show()



I hope it helps, let me know wether you need a different approach!
2011/5/25 Karthikraja Velmurugan <velmurugan.karthikr...@gmail.com>

>  Hello friends,
>
>
>
> I am a newbee to matplotlib and I am trying to plot (scatter plot) some
> values. The data is quite big and I have them in a CSV file. For a starter I
> thought I will use *loadrec.py* example to see if I am able to import the
> data from the CSV file. The loadrec.py goes like this:
>
>
>
> from matplotlib import mlab
>
> from pylab import figure, show
>
> import matplotlib.cbook as cbook
>
>
>
> datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
>
> print 'loading', datafile
>
> a = mlab.csv2rec(datafile)
>
> a.sort()
>
> print a.dtype
>
>
>
> fig = figure()
>
> ax = fig.add_subplot(111)
>
> ax.plot(a.date, a.adj_close, '-')
>
> fig.autofmt_xdate()
>
>  I believe, for the CSV file to be accessed, it has to be placed in the *
> sample_data* folder (for windows). So I placed my csv file in the
> sample_data folder and ran the script.
>
>
>
> The output was
>
>
>
> *Traceback (most recent call last):*
>
> *  File "C:\Python26\loadrec.py", line 5, in <module>*
>
> *    datafile = cbook.get_sample_data('ch1.csv', asfileobj=False)*
>
> *  File "C:\Python26\Lib\site-packages\matplotlib\cbook.py", line 662, in
> get_sample_data*
>
> *    return myserver.get_sample_data(fname, asfileobj=asfileobj)*
>
> *  File "C:\Python26\Lib\site-packages\matplotlib\cbook.py", line 620, in
> get_sample_data*
>
> *    raise KeyError(msg)*
>
> *KeyError: 'file ch1.csv not in cache; received HTTP Error 404: Not Found
> when trying to retrieve'*
>
>
>
> The data in my CSV file looks like this
>
>
>
> 0.9963
>
> 0
>
> 0.499
>
> 0.9901
>
> 0.0025
>
> 0
>
> 1
>
> 0.0017
>
> 1
>
> 0.0173
>
> 0.9837
>
> If anyone can understand the problem please give me your suggestions. I
> will be very thankful if any of you can show me exactly how to scatter plot
> this kind of data.
>
>
>
> *Karthikraja Velmurugan, *
>
> *Graduate research assistant, *
>
> *Dept of Biomedical Informatics, *
>
> *Arizona State University, *
>
> *248-421-7394*
>
>
>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to