|
From: Sayan C. <say...@gm...> - 2013-03-27 08:33:46
|
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 Volunteer , Padakshep www.padakshep.org |
|
From: Florian M. W. <wag...@st...> - 2013-03-27 10:20:54
|
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 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> > > Volunteer , Padakshep > www.padakshep.org <http://www.padakshep.org> > > > ------------------------------------------------------------------------------ > Own the Future-Intel® 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 > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Sayan C. <say...@gm...> - 2013-03-27 12:17:32
|
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 <wag...@st...> 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 > > 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 > > Volunteer , Padakshep > www.padakshep.org > > > ------------------------------------------------------------------------------ > Own the Future-Intel® 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 > > > > _______________________________________________ > Matplotlib-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > Own the Future-Intel® 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 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > 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 Volunteer , Padakshep www.padakshep.org |
|
From: Steven B. <bo...@ph...> - 2013-03-27 14:28:54
|
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 <wag...@st... > <mailto:wag...@st...>> 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 > > 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> >> >> Volunteer , Padakshep >> www.padakshep.org <http://www.padakshep.org> >> >> >> ------------------------------------------------------------------------------ >> Own the Future-Intel® 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 >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... <mailto:Mat...@li...> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ------------------------------------------------------------------------------ > Own the Future-Intel® 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 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > 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> > > Volunteer , Padakshep > www.padakshep.org <http://www.padakshep.org> > > > ------------------------------------------------------------------------------ > Own the Future-Intel® 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 > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas A&M University bo...@ph... |
|
From: Sayan C. <say...@gm...> - 2013-03-27 15:08:00
|
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...@ph...> 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 <wag...@st... >> <mailto:wag...@st....**ch <wag...@st...>>> 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> >> >> 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> >>> > >>> >>> Volunteer , Padakshep >>> www.padakshep.org <http://www.padakshep.org> >>> >>> >>> >>> ------------------------------**------------------------------** >>> ------------------ >>> Own the Future-Intel® 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> >>> >>> >>> ______________________________**_________________ >>> Matplotlib-users mailing list >>> Matplotlib-users@lists.**sourceforge.net<Mat...@li...> <mailto: >>> Matplotlib-users@**lists.sourceforge.net<Mat...@li...> >>> > >>> https://lists.sourceforge.net/**lists/listinfo/matplotlib-**users<https://lists.sourceforge.net/lists/listinfo/matplotlib-users> >>> >> >> >> ------------------------------**------------------------------** >> ------------------ >> Own the Future-Intel® 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> >> ______________________________**_________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.**sourceforge.net<Mat...@li...> >> <mailto:Matplotlib-users@**lists.sourceforge.net<Mat...@li...> >> > >> 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> >> > >> >> Volunteer , Padakshep >> www.padakshep.org <http://www.padakshep.org> >> >> >> >> ------------------------------**------------------------------** >> ------------------ >> Own the Future-Intel® 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> >> >> >> ______________________________**_________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.**sourceforge.net<Mat...@li...> >> 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...@ph... > -- -------------------------------------------------------------------------- *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 |
|
From: Steven B. <bo...@ph...> - 2013-03-27 21:18:09
|
Hey Sayan, Here is the manual page: 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...@ph... > <mailto:bo...@ph...>> 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 > <wag...@st... <mailto:wag...@st...> > <mailto:wag...@st....__ch > <mailto:wag...@st...>>> 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> > > 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.blogspot.com>> > > Volunteer , Padakshep > www.padakshep.org <http://www.padakshep.org> > <http://www.padakshep.org> > > > > > ------------------------------__------------------------------__------------------ > Own the Future-Intel® 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> > > > _________________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.__sourceforge.net > <mailto:Mat...@li...> > <mailto:Matplotlib-users@__lists.sourceforge.net > <mailto:Mat...@li...>> > https://lists.sourceforge.net/__lists/listinfo/matplotlib-__users > <https://lists.sourceforge.net/lists/listinfo/matplotlib-users> > > > > > ------------------------------__------------------------------__------------------ > Own the Future-Intel® 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> > _________________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.__sourceforge.net > <mailto:Mat...@li...> > <mailto:Matplotlib-users@__lists.sourceforge.net > <mailto:Mat...@li...>> > 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.blogspot.com>> > > Volunteer , Padakshep > www.padakshep.org <http://www.padakshep.org> > <http://www.padakshep.org> > > > > ------------------------------__------------------------------__------------------ > Own the Future-Intel® 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> > > > _________________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.__sourceforge.net > <mailto:Mat...@li...> > 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...@ph... <mailto:bo...@ph...> > > > > > -- > > > -------------------------------------------------------------------------- > *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> > > Volunteer , Padakshep > www.padakshep.org <http://www.padakshep.org> -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas A&M University bo...@ph... |
|
From: Sayan C. <say...@gm...> - 2013-03-31 15:51:54
|
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...@ph...> 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...@ph... >> <mailto:bo...@ph...**>> 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 >> <wag...@st... <mailto:wag...@st....**ch<wag...@st...> >> > >> <mailto:wag...@st....**__ch >> >> <mailto:wag...@st....**ch <wag...@st...>>>> >> 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® 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<Mat...@li...> >> > >> <mailto:Matplotlib-users@__lis**ts.sourceforge.net<http://lists.sourceforge.net> >> <mailto:Matplotlib-users@**lists.sourceforge.net<Mat...@li...> >> >> >> 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® 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<Mat...@li...> >> > >> <mailto:Matplotlib-users@__lis**ts.sourceforge.net<http://lists.sourceforge.net> >> <mailto:Matplotlib-users@**lists.sourceforge.net<Mat...@li...> >> >> >> 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® 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<Mat...@li...> >> > >> 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...@ph... <mailto:bo...@ph...**> >> >> >> >> >> >> -- >> >> >> ------------------------------**------------------------------** >> -------------- >> *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...@ph... > -- -------------------------------------------------------------------------- *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 |
|
From: Benjamin R. <ben...@ou...> - 2013-04-01 01:32:39
|
On Sun, Mar 31, 2013 at 11:51 AM, Sayan Chatterjee < say...@gm...> wrote: > 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() > > Sayan, Try putting "plt.cla()" after the call to "pylab.savefig()". Ben Root |
|
From: Sayan C. <say...@gm...> - 2013-04-01 11:30:28
|
Thank you very much!!...'plt.cla()' worked!! One slight hiccup. Could you please tell me how to fix up the Y grid? I mean I want every plot to have scale from 0 to 15 (say), not that some will have -5 to 10 and some will have 5 to 20.Is it possible?...it's absolutely necessary for the concerned simulation. :) Sayan On 1 April 2013 07:02, Benjamin Root <ben...@ou...> wrote: > > > > On Sun, Mar 31, 2013 at 11:51 AM, Sayan Chatterjee < > say...@gm...> wrote: > >> 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() >> >> > Sayan, > > Try putting "plt.cla()" after the call to "pylab.savefig()". > > Ben Root > -- -------------------------------------------------------------------------- *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 |
|
From: Benjamin R. <ben...@ou...> - 2013-04-01 13:32:15
|
On Mon, Apr 1, 2013 at 7:29 AM, Sayan Chatterjee <say...@gm...>wrote: > Thank you very much!!...'plt.cla()' worked!! > > One slight hiccup. Could you please tell me how to fix up the Y grid? I > mean I want every plot to have scale from 0 to 15 (say), not that some will > have -5 to 10 and some will have 5 to 20.Is it possible?...it's > absolutely necessary for the concerned simulation. > > :) > Sayan > > put "plt.ylim(0, 15) " before the call to savefig(). Ben Root |
|
From: Sayan C. <say...@gm...> - 2013-04-01 14:00:23
|
Thanks Benjamin...I put that plt.ylim earlier but at a wrong place. It worked. Thanks again! On 1 April 2013 19:01, Benjamin Root <ben...@ou...> wrote: > > > On Mon, Apr 1, 2013 at 7:29 AM, Sayan Chatterjee < > say...@gm...> wrote: > >> Thank you very much!!...'plt.cla()' worked!! >> >> One slight hiccup. Could you please tell me how to fix up the Y grid? I >> mean I want every plot to have scale from 0 to 15 (say), not that some will >> have -5 to 10 and some will have 5 to 20.Is it possible?...it's >> absolutely necessary for the concerned simulation. >> >> :) >> Sayan >> >> > put "plt.ylim(0, 15) " before the call to savefig(). > > Ben Root > > -- -------------------------------------------------------------------------- *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 |