Thank you very much I have been able to plot from the data files, but
facing a slight glitch. The data points are being super imposed in
consecutive plots.That means if the 1st data file contains 50 points and
the second 30. The second plot will contain 80 points! How to go about this
problem?

for i in range(0,20):
  fname = 'file_' + str(i) + '.dat'
  f=open(fname,"r")
  x,y = np.loadtxt(fname, unpack=True)
  plt.scatter(x,y)
  pylab.savefig(fname + '.png')
  f.close()


On 28 March 2013 02:48, Steven Boada <bo...@physics.tamu.edu> wrote:

> Hey Sayan,
>
> Here is the manual page:
>
> http://docs.scipy.org/doc/**numpy/reference/generated/**
> numpy.genfromtxt.html<http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html>
>
> It works (basically) the same as loadtxt, but it is more flexible when
> there are holes in your data.
>
> Good luck.
>
> Steven
>
>
> On Wed Mar 27 10:07:10 2013, Sayan Chatterjee wrote:
>
>> Hi Steven,
>>
>> I am a newbie to Python and hence Matplotlib. I cannot get your point
>> properly. Could you please redirect me to a page where the usage is
>> demonstrated?
>>
>> As I can see, you're a doctoral student in Physics, it might be
>> worthwhile to tell you that I'm trying to code a  Zeldovich
>> Approximation for a simple sinusoidal potential and want to make it
>> evolve with varying scale factor and make an animation of it.
>>
>> Cheers,
>> Sayan
>>
>>
>> On 27 March 2013 19:58, Steven Boada <bo...@physics.tamu.edu
>> <mailto:bo...@physics.tamu.edu**>> wrote:
>>
>>     Another, slightly more flexible, option is the genfromtxt
>>     function, also in numpy. Normally you should try genfromtxt after
>>     loadtxt doesn't work. Or, that is my normal method.
>>
>>     Steven
>>
>>
>>     On Wed Mar 27 07:16:45 2013, Sayan Chatterjee wrote:
>>
>>         Thank you very much for your prompt reply.
>>
>>         Florian,  your reply seems to be the answer to my question.
>>         I'll try
>>         it out. If can't figure out,I'll get back to you.
>>
>>
>>         On 27 March 2013 15:37, Florian M. Wagner
>>         <wagne...@student.ethz.ch 
>> <mailto:wagne...@student.ethz.**ch<wagne...@student.ethz.ch>
>> >
>>         <mailto:wagne...@student.ethz.**__ch
>>
>>         <mailto:wagne...@student.ethz.**ch <wagne...@student.ethz.ch>>>>
>> wrote:
>>
>>             Hey Sayan,
>>
>>             for reading in simple ASCII-Files containing your two
>>         arrays you
>>             should have a look at the numpy.loadtxt function.
>>
>>             Scatter plots in matplotlib are then easily created as
>>         shown here
>>         http://matplotlib.org/__**examples/pylab_examples/__**
>> scatter_demo.html<http://matplotlib.org/__examples/pylab_examples/__scatter_demo.html>
>>
>>         <http://matplotlib.org/**examples/pylab_examples/**
>> scatter_demo.html<http://matplotlib.org/examples/pylab_examples/scatter_demo.html>
>> >
>>
>>             For your purpose you can do something like:
>>
>>                 import os
>>                 import numpy as np
>>                 import matplotlib.pyplot as plt
>>
>>                 for file in os.path.listdir():
>>                     x, y = np.loadtxt(file, unpack=True)
>>                     plt.scatter(x,y)
>>                     plt.savefig(file + '.png')
>>
>>             Cheers,
>>
>>             Florian
>>
>>
>>             Am 27.03.2013 09:32, schrieb Sayan Chatterjee:
>>
>>                 Dear All,
>>
>>                 I'm new to Matplotlib. It might be a silly question,
>>             how does one
>>                 plot data(not functions) in Matplotlib.
>>
>>                 How:
>>                 1)Two arrays (X and Y) can be plotted in a scatter
>>             diagram?
>>
>>                 2) or a number of data files can used to produce
>>             different plots
>>                 having different(sequential) name?
>>
>>                 Thanks in anticipation.
>>                 Regards,
>>                 Sayan
>>
>>                 --
>>
>>
>>
>>             ------------------------------**
>> __----------------------------**--__--------------
>>
>>                 *Sayan  Chatterjee*
>>
>>                 Dept. of Physics and Meteorology
>>                 IIT Kharagpur
>>                 Lal Bahadur Shastry Hall of Residence
>>                 Room AB 205
>>                 Mob: +91 9874513565
>>                 blog: www.blissprofound.blogspot.com
>>             
>> <http://www.blissprofound.**blogspot.com<http://www.blissprofound.blogspot.com>
>> >
>>                 
>> <http://www.blissprofound.__bl**ogspot.com<http://blogspot.com>
>>
>>             
>> <http://www.blissprofound.**blogspot.com<http://www.blissprofound.blogspot.com>
>> >>
>>
>>                 Volunteer , Padakshep
>>             www.padakshep.org <http://www.padakshep.org>
>>             <http://www.padakshep.org>
>>
>>
>>
>>
>>             ------------------------------**
>> __----------------------------**--__------------------
>>
>>                 Own the Future-Intel&reg; Level Up Game Demo Contest 2013
>>                 Rise to greatness in Intel's independent game demo
>>             contest.
>>                 Compete for recognition, cash, and the chance to get
>>             your game
>>                 on Steam. $5K grand prize plus 10 genre and skill prizes.
>>                 Submit your demo by
>>             
>> 6/6/13.http://p.sf.net/sfu/__**intel_levelupd2d<http://p.sf.net/sfu/__intel_levelupd2d>
>>             
>> <http://p.sf.net/sfu/intel_**levelupd2d<http://p.sf.net/sfu/intel_levelupd2d>
>> >
>>
>>
>>                 ______________________________**___________________
>>                 Matplotlib-users mailing list
>>             
>> Matplotlib-users@lists.__sourc**eforge.net<http://sourceforge.net>
>>             
>> <mailto:Matplotlib-users@**lists.sourceforge.net<Matplotlib-users@lists.sourceforge.net>
>> >
>>              
>> <mailto:Matplotlib-users@__lis**ts.sourceforge.net<http://lists.sourceforge.net>
>>             
>> <mailto:Matplotlib-users@**lists.sourceforge.net<Matplotlib-users@lists.sourceforge.net>
>> >>
>>             https://lists.sourceforge.net/**
>> __lists/listinfo/matplotlib-__**users<https://lists.sourceforge.net/__lists/listinfo/matplotlib-__users>
>>             <https://lists.sourceforge.**net/lists/listinfo/matplotlib-**
>> users <https://lists.sourceforge.net/lists/listinfo/matplotlib-users>>
>>
>>
>>
>>
>>         ------------------------------**__----------------------------**
>> --__------------------
>>
>>             Own the Future-Intel&reg; Level Up Game Demo Contest 2013
>>             Rise to greatness in Intel's independent game demo contest.
>>             Compete for recognition, cash, and the chance to get your game
>>             on Steam. $5K grand prize plus 10 genre and skill prizes.
>>             Submit your demo by 6/6/13.
>>         
>> http://p.sf.net/sfu/intel___**levelupd2d<http://p.sf.net/sfu/intel___levelupd2d>
>>         
>> <http://p.sf.net/sfu/intel_**levelupd2d<http://p.sf.net/sfu/intel_levelupd2d>
>> >
>>             ______________________________**___________________
>>             Matplotlib-users mailing list
>>         Matplotlib-users@lists.__sourc**eforge.net<http://sourceforge.net>
>>         
>> <mailto:Matplotlib-users@**lists.sourceforge.net<Matplotlib-users@lists.sourceforge.net>
>> >
>>             
>> <mailto:Matplotlib-users@__lis**ts.sourceforge.net<http://lists.sourceforge.net>
>>         
>> <mailto:Matplotlib-users@**lists.sourceforge.net<Matplotlib-users@lists.sourceforge.net>
>> >>
>>         https://lists.sourceforge.net/**__lists/listinfo/matplotlib-__**
>> users <https://lists.sourceforge.net/__lists/listinfo/matplotlib-__users>
>>         <https://lists.sourceforge.**net/lists/listinfo/matplotlib-**
>> users <https://lists.sourceforge.net/lists/listinfo/matplotlib-users>>
>>
>>
>>
>>
>>         --
>>
>>
>>         ------------------------------**__----------------------------**
>> --__--------------
>>
>>         *Sayan  Chatterjee*
>>
>>         Dept. of Physics and Meteorology
>>         IIT Kharagpur
>>         Lal Bahadur Shastry Hall of Residence
>>         Room AB 205
>>         Mob: +91 9874513565
>>         blog: www.blissprofound.blogspot.com
>>         
>> <http://www.blissprofound.**blogspot.com<http://www.blissprofound.blogspot.com>
>> >
>>         <http://www.blissprofound.__bl**ogspot.com <http://blogspot.com>
>>
>>         
>> <http://www.blissprofound.**blogspot.com<http://www.blissprofound.blogspot.com>
>> >>
>>
>>         Volunteer , Padakshep
>>         www.padakshep.org <http://www.padakshep.org>
>>         <http://www.padakshep.org>
>>
>>
>>
>>         ------------------------------**__----------------------------**
>> --__------------------
>>
>>         Own the Future-Intel&reg; Level Up Game Demo Contest 2013
>>         Rise to greatness in Intel's independent game demo contest.
>>         Compete for recognition, cash, and the chance to get your game
>>         on Steam. $5K grand prize plus 10 genre and skill prizes.
>>         Submit your demo by 6/6/13.
>>         
>> http://p.sf.net/sfu/intel___**levelupd2d<http://p.sf.net/sfu/intel___levelupd2d>
>>         
>> <http://p.sf.net/sfu/intel_**levelupd2d<http://p.sf.net/sfu/intel_levelupd2d>
>> >
>>
>>
>>         ______________________________**___________________
>>         Matplotlib-users mailing list
>>         Matplotlib-users@lists.__sourc**eforge.net<http://sourceforge.net>
>>         
>> <mailto:Matplotlib-users@**lists.sourceforge.net<Matplotlib-users@lists.sourceforge.net>
>> >
>>         https://lists.sourceforge.net/**__lists/listinfo/matplotlib-__**
>> users <https://lists.sourceforge.net/__lists/listinfo/matplotlib-__users>
>>
>>         <https://lists.sourceforge.**net/lists/listinfo/matplotlib-**
>> users <https://lists.sourceforge.net/lists/listinfo/matplotlib-users>>
>>
>>
>>     --
>>
>>     Steven Boada
>>
>>     Doctoral Student
>>     Dept of Physics and Astronomy
>>     Texas A&M University
>>     bo...@physics.tamu.edu <mailto:bo...@physics.tamu.edu**>
>>
>>
>>
>>
>>
>> --
>>
>>
>> ------------------------------**------------------------------**
>> --------------
>> *Sayan  Chatterjee*
>> Dept. of Physics and Meteorology
>> IIT Kharagpur
>> Lal Bahadur Shastry Hall of Residence
>> Room AB 205
>> Mob: +91 9874513565
>> blog: www.blissprofound.blogspot.com
>> <http://www.blissprofound.**blogspot.com<http://www.blissprofound.blogspot.com>
>> >
>>
>> Volunteer , Padakshep
>> www.padakshep.org <http://www.padakshep.org>
>>
>
> --
>
> Steven Boada
>
> Doctoral Student
> Dept of Physics and Astronomy
> Texas A&M University
> bo...@physics.tamu.edu
>



-- 


--------------------------------------------------------------------------
*Sayan  Chatterjee*
Dept. of Physics and Meteorology
IIT Kharagpur
Lal Bahadur Shastry Hall of Residence
Room AB 205
Mob: +91 9874513565
blog: www.blissprofound.blogspot.com

Volunteer , Padakshep
www.padakshep.org
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to