## Re: [Matplotlib-users] 2D Radial Plots

 Re: [Matplotlib-users] 2D Radial Plots From: Benoit Donnet - 2007-06-26 06:17:20 ```Hey, That's quite simple. Assume your file containing the data is name =20 Data.dat and is in the same directory than your python script. from pylab import * from numpy import * tab =3D load('Data.dat') #load the file r =3D tab[:,0] #get the r coordinates theta =3D tab[:,1] #get the theta coordinates T =3D tab[:,2] #get the temperature # now, you can process/plot your data Hope this help. Best regards. Benoit Le 25-juin-07 =E0 19:03, Lorenzo Isella a =E9crit : > Dear All, > I am quite a newbie about Python and Pylab, but I am starting to like > the ease you can develop with using these tools. > I am interested in 2D radial plots (think for instance about the plot > of the temperature along the cross-section of a pipe). > I had a look at the tutorial online, in particular to the case =20 > described in: > > http://matplotlib.sourceforge.net/screenshots/polar_demo.py > > but there is something which is not 100% clear to me. > What if, instead of having an analytical expression for the quantity I > want to plot I have to read it (together with the r and theta > coordinates) from a file, e.g.: > > r theta T > > > where the columns r and theta contain the list of (r,theta) > coordinates (the "grid" I am using along the cross section) and T the > temperature evaluated at that grid point? > If necessary, I can post an example file (but at the moment I am > working with fairly big files and I think I conveyed an idea of what I > am after). > Many thanks > > Lorenzo > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Benoit Donnet Universit=E9 Catholique de Louvain (UCL) Facult=E9 des Sciences Appliqu=E9es - D=E9partement d'Ing=E9nierie =20 Informatique (INGI) Place Sainte Barbe, 2 1348 Louvain-la-Neuve Belgium Phone: +32 10 47 87 18 Home page: http://inl.info.ucl.ac.be/donnet ```

 [Matplotlib-users] 2D Radial Plots From: Lorenzo Isella - 2007-06-25 17:03:41 ```Dear All, I am quite a newbie about Python and Pylab, but I am starting to like the ease you can develop with using these tools. I am interested in 2D radial plots (think for instance about the plot of the temperature along the cross-section of a pipe). I had a look at the tutorial online, in particular to the case described in: http://matplotlib.sourceforge.net/screenshots/polar_demo.py but there is something which is not 100% clear to me. What if, instead of having an analytical expression for the quantity I want to plot I have to read it (together with the r and theta coordinates) from a file, e.g.: r theta T where the columns r and theta contain the list of (r,theta) coordinates (the "grid" I am using along the cross section) and T the temperature evaluated at that grid point? If necessary, I can post an example file (but at the moment I am working with fairly big files and I think I conveyed an idea of what I am after). Many thanks Lorenzo ```
 Re: [Matplotlib-users] 2D Radial Plots From: Benoit Donnet - 2007-06-26 06:17:20 ```Hey, That's quite simple. Assume your file containing the data is name =20 Data.dat and is in the same directory than your python script. from pylab import * from numpy import * tab =3D load('Data.dat') #load the file r =3D tab[:,0] #get the r coordinates theta =3D tab[:,1] #get the theta coordinates T =3D tab[:,2] #get the temperature # now, you can process/plot your data Hope this help. Best regards. Benoit Le 25-juin-07 =E0 19:03, Lorenzo Isella a =E9crit : > Dear All, > I am quite a newbie about Python and Pylab, but I am starting to like > the ease you can develop with using these tools. > I am interested in 2D radial plots (think for instance about the plot > of the temperature along the cross-section of a pipe). > I had a look at the tutorial online, in particular to the case =20 > described in: > > http://matplotlib.sourceforge.net/screenshots/polar_demo.py > > but there is something which is not 100% clear to me. > What if, instead of having an analytical expression for the quantity I > want to plot I have to read it (together with the r and theta > coordinates) from a file, e.g.: > > r theta T > > > where the columns r and theta contain the list of (r,theta) > coordinates (the "grid" I am using along the cross section) and T the > temperature evaluated at that grid point? > If necessary, I can post an example file (but at the moment I am > working with fairly big files and I think I conveyed an idea of what I > am after). > Many thanks > > Lorenzo > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Benoit Donnet Universit=E9 Catholique de Louvain (UCL) Facult=E9 des Sciences Appliqu=E9es - D=E9partement d'Ing=E9nierie =20 Informatique (INGI) Place Sainte Barbe, 2 1348 Louvain-la-Neuve Belgium Phone: +32 10 47 87 18 Home page: http://inl.info.ucl.ac.be/donnet ```
 Re: [Matplotlib-users] 2D Radial Plots From: Lorenzo Isella - 2007-06-26 13:36:35 Attachments: example.txt ```Hello, Thanks for your suggestion, but I still have a problem. Maybe I did not make myself clear (or most likely I have a problem about how to implement your suggestion): actually I have T=3DT(r,theta) and I would like to make a 2D plot using colors such that one can see that the domain where I am plotting is actually a circle. The example I mentioned is not exactly what I need since there one can find how to plot in polar coordinates a function of r alone. Furthermore, I do not have necessarily an equally spaced grid. For instance, let me consider the case of 5 theta's and 7 radial position and consequentely 35 values of T: theta R T 0.000000000000000000e+00 0.000000000000000000e+00 5.459815003314423620e+01 0.000000000000000000e+00 1.666666666666666574e-01 4.853828855239110851e+01 0.000000000000000000e+00 3.333333333333333148e-01 4.315101251901344881e+01 0.000000000000000000e+00 5.000000000000000000e-01 3.836167151642037965e+01 0.000000000000000000e+00 6.666666666666666297e-01 3.410390059527122020e+01 0.000000000000000000e+00 8.333333333333332593e-01 3.031870066752165016e+01 0.000000000000000000e+00 1.000000000000000000e+00 2.695362096775039973e+01 1.570796326794896558e+00 0.000000000000000000e+00 2.396203225329512776e+01 1.570796326794896558e+00 1.666666666666666574e-01 2.130248067207563523e+01 1.570796326794896558e+00 3.333333333333333148e-01 1.893811334477913277e+01 1.570796326794896558e+00 5.000000000000000000e-01 1.683616770181326316e+01 1.570796326794896558e+00 6.666666666666666297e-01 1.496751749887080329e+01 1.570796326794896558e+00 8.333333333333332593e-01 1.330626922033307302e+01 1.570796326794896558e+00 1.000000000000000000e+00 1.182940327795447999e+01 3.141592653589793116e+00 0.000000000000000000e+00 1.051645503298913731e+01 3.141592653589793116e+00 1.666666666666666574e-01 9.349231221746512333e+00 3.141592653589793116e+00 3.333333333333333148e-01 8.311557855141172624e+00 3.141592653589793116e+00 5.000000000000000000e-01 7.389056098930650407e+00 3.141592653589793116e+00 6.666666666666666297e-01 6.568943029058285532e+00 3.141592653589793116e+00 8.333333333333332593e-01 5.839854501207304871e+00 3.141592653589793116e+00 1.000000000000000000e+00 5.191687680104649871e+00 4.712388980384689674e+00 0.000000000000000000e+00 4.615461046534314882e+00 4.712388980384689674e+00 1.666666666666666574e-01 4.103189942205120566e+00 4.712388980384689674e+00 3.333333333333333148e-01 3.647775927922803252e+00 4.712388980384689674e+00 5.000000000000000000e-01 3.242908421924544982e+00 4.712388980384689674e+00 6.666666666666666297e-01 2.882977255397825012e+00 4.712388980384689674e+00 8.333333333333332593e-01 2.562994933482758420e+00 4.712388980384689674e+00 1.000000000000000000e+00 2.278527524544009530e+00 6.283185307179586232e+00 0.000000000000000000e+00 2.025633220058637107e+00 6.283185307179586232e+00 1.666666666666666574e-01 1.800807713756398032e+00 6.283185307179586232e+00 3.333333333333333148e-01 1.600935643142084031e+00 6.283185307179586232e+00 5.000000000000000000e-01 1.423247420534685892e+00 6.283185307179586232e+00 6.666666666666666297e-01 1.265280855439646635e+00 6.283185307179586232e+00 8.333333333333332593e-01 1.124847036463023642e+00 6.283185307179586232e+00 1.000000000000000000e+00 1.000000000000000000e+00 How would you plot them in order to have a 2D-color plot where one can understand we are working on a circle (well, maybe it will look like something different since I have only a few grid points, but the aim is clear, I hope)? Kind Regards Lorenzo On 26/06/07, Benoit Donnet wrote: > Hey, > > That's quite simple. Assume your file containing the data is name > Data.dat and is in the same directory than your python script. > > from pylab import * > from numpy import * > > tab =3D load('Data.dat') #load the file > r =3D tab[:,0] #get the r coordinates > theta =3D tab[:,1] #get the theta coordinates > T =3D tab[:,2] #get the temperature > > # now, you can process/plot your data > > Hope this help. > > Best regards. > > Benoit > > > Le 25-juin-07 =E0 19:03, Lorenzo Isella a =E9crit : > > > Dear All, > > I am quite a newbie about Python and Pylab, but I am starting to like > > the ease you can develop with using these tools. > > I am interested in 2D radial plots (think for instance about the plot > > of the temperature along the cross-section of a pipe). > > I had a look at the tutorial online, in particular to the case > > described in: > > > > http://matplotlib.sourceforge.net/screenshots/polar_demo.py > > > > but there is something which is not 100% clear to me. > > What if, instead of having an analytical expression for the quantity I > > want to plot I have to read it (together with the r and theta > > coordinates) from a file, e.g.: > > > > r theta T > > > > > > where the columns r and theta contain the list of (r,theta) > > coordinates (the "grid" I am using along the cross section) and T the > > temperature evaluated at that grid point? > > If necessary, I can post an example file (but at the moment I am > > working with fairly big files and I think I conveyed an idea of what I > > am after). > > Many thanks > > > > Lorenzo > > > > ---------------------------------------------------------------------- > > --- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- > Dr. Benoit Donnet > Universit=E9 Catholique de Louvain (UCL) > Facult=E9 des Sciences Appliqu=E9es - D=E9partement d'Ing=E9nierie > Informatique (INGI) > Place Sainte Barbe, 2 > 1348 Louvain-la-Neuve > Belgium > Phone: +32 10 47 87 18 > Home page: http://inl.info.ucl.ac.be/donnet > > > > ```
 Re: [Matplotlib-users] 2D Radial Plots From: Brian - 2007-06-26 15:14:38 Attachments: Message as HTML ```It sounds to me that you want to have a contour plot which takes as input the r,theta, and T. I would suggest just On 6/26/07, Lorenzo Isella wrote: > > Hello, > Thanks for your suggestion, but I still have a problem. > Maybe I did not make myself clear (or most likely I have a problem > about how to implement your suggestion): actually I have T=3DT(r,theta) > and I would like to make a 2D plot using colors such that one can see > that the domain where I am plotting is actually a circle. > The example I mentioned is not exactly what I need since there one can > find how to plot in polar coordinates a function of r alone. > Furthermore, I do not have necessarily an equally spaced grid. > For instance, let me consider the case of 5 theta's and 7 radial > position and consequentely 35 values of T: > > theta R > T > 0.000000000000000000e+00 0.000000000000000000e+00 5.459815003314423620e+0= 1 > 0.000000000000000000e+00 1.666666666666666574e-01 4.853828855239110851e+0= 1 > 0.000000000000000000e+00 3.333333333333333148e-01 4.315101251901344881e+0= 1 > 0.000000000000000000e+00 5.000000000000000000e-01 3.836167151642037965e+0= 1 > 0.000000000000000000e+00 6.666666666666666297e-01 3.410390059527122020e+0= 1 > 0.000000000000000000e+00 8.333333333333332593e-01 3.031870066752165016e+0= 1 > 0.000000000000000000e+00 1.000000000000000000e+00 2.695362096775039973e+0= 1 > 1.570796326794896558e+00 0.000000000000000000e+00 2.396203225329512776e+0= 1 > 1.570796326794896558e+00 1.666666666666666574e-01 2.130248067207563523e+0= 1 > 1.570796326794896558e+00 3.333333333333333148e-01 1.893811334477913277e+0= 1 > 1.570796326794896558e+00 5.000000000000000000e-01 1.683616770181326316e+0= 1 > 1.570796326794896558e+00 6.666666666666666297e-01 1.496751749887080329e+0= 1 > 1.570796326794896558e+00 8.333333333333332593e-01 1.330626922033307302e+0= 1 > 1.570796326794896558e+00 1.000000000000000000e+00 1.182940327795447999e+0= 1 > 3.141592653589793116e+00 0.000000000000000000e+00 1.051645503298913731e+0= 1 > 3.141592653589793116e+00 1.666666666666666574e-01 9.349231221746512333e+0= 0 > 3.141592653589793116e+00 3.333333333333333148e-01 8.311557855141172624e+0= 0 > 3.141592653589793116e+00 5.000000000000000000e-01 7.389056098930650407e+0= 0 > 3.141592653589793116e+00 6.666666666666666297e-01 6.568943029058285532e+0= 0 > 3.141592653589793116e+00 8.333333333333332593e-01 5.839854501207304871e+0= 0 > 3.141592653589793116e+00 1.000000000000000000e+00 5.191687680104649871e+0= 0 > 4.712388980384689674e+00 0.000000000000000000e+00 4.615461046534314882e+0= 0 > 4.712388980384689674e+00 1.666666666666666574e-01 4.103189942205120566e+0= 0 > 4.712388980384689674e+00 3.333333333333333148e-01 3.647775927922803252e+0= 0 > 4.712388980384689674e+00 5.000000000000000000e-01 3.242908421924544982e+0= 0 > 4.712388980384689674e+00 6.666666666666666297e-01 2.882977255397825012e+0= 0 > 4.712388980384689674e+00 8.333333333333332593e-01 2.562994933482758420e+0= 0 > 4.712388980384689674e+00 1.000000000000000000e+00 2.278527524544009530e+0= 0 > 6.283185307179586232e+00 0.000000000000000000e+00 2.025633220058637107e+0= 0 > 6.283185307179586232e+00 1.666666666666666574e-01 1.800807713756398032e+0= 0 > 6.283185307179586232e+00 3.333333333333333148e-01 1.600935643142084031e+0= 0 > 6.283185307179586232e+00 5.000000000000000000e-01 1.423247420534685892e+0= 0 > 6.283185307179586232e+00 6.666666666666666297e-01 1.265280855439646635e+0= 0 > 6.283185307179586232e+00 8.333333333333332593e-01 1.124847036463023642e+0= 0 > 6.283185307179586232e+00 1.000000000000000000e+00 1.000000000000000000e+0= 0 > > > > How would you plot them in order to have a 2D-color plot where one can > understand we are working on a circle (well, maybe it will look like > something different since I have only a few grid points, but the aim > is clear, I hope)? > Kind Regards > > Lorenzo > > > > > > On 26/06/07, Benoit Donnet wrote: > > Hey, > > > > That's quite simple. Assume your file containing the data is name > > Data.dat and is in the same directory than your python script. > > > > from pylab import * > > from numpy import * > > > > tab =3D load('Data.dat') #load the file > > r =3D tab[:,0] #get the r coordinates > > theta =3D tab[:,1] #get the theta coordinates > > T =3D tab[:,2] #get the temperature > > > > # now, you can process/plot your data > > > > Hope this help. > > > > Best regards. > > > > Benoit > > > > > > Le 25-juin-07 =E0 19:03, Lorenzo Isella a =E9crit : > > > > > Dear All, > > > I am quite a newbie about Python and Pylab, but I am starting to like > > > the ease you can develop with using these tools. > > > I am interested in 2D radial plots (think for instance about the plot > > > of the temperature along the cross-section of a pipe). > > > I had a look at the tutorial online, in particular to the case > > > described in: > > > > > > http://matplotlib.sourceforge.net/screenshots/polar_demo.py > > > > > > but there is something which is not 100% clear to me. > > > What if, instead of having an analytical expression for the quantity = I > > > want to plot I have to read it (together with the r and theta > > > coordinates) from a file, e.g.: > > > > > > r theta T > > > > > > > > > where the columns r and theta contain the list of (r,theta) > > > coordinates (the "grid" I am using along the cross section) and T the > > > temperature evaluated at that grid point? > > > If necessary, I can post an example file (but at the moment I am > > > working with fairly big files and I think I conveyed an idea of what = I > > > am after). > > > Many thanks > > > > > > Lorenzo > > > > > > ---------------------------------------------------------------------= - > > > --- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Matplotlib-users mailing list > > > Matplotlib-users@... > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > -- > > Dr. Benoit Donnet > > Universit=E9 Catholique de Louvain (UCL) > > Facult=E9 des Sciences Appliqu=E9es - D=E9partement d'Ing=E9nierie > > Informatique (INGI) > > Place Sainte Barbe, 2 > > 1348 Louvain-la-Neuve > > Belgium > > Phone: +32 10 47 87 18 > > Home page: http://inl.info.ucl.ac.be/donnet > > > > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ```
 Re: [Matplotlib-users] 2D Radial Plots From: Lorenzo Isella - 2007-06-26 15:42:36 ```Hello, Sorry for this tread getting quite long, but I am not getting there yet. Online I found examples like: #! /usr/bin/env python from pylab import * x=arange(-2,2,0.1) y=arange(-2,2,0.05) X,Y=meshgrid(x,y) z=exp(-(X*X + Y*Y)) + 0.6*exp(-((X+1.8)**2 + Y**2)) #contour(x,y,z,arange(0,1,0.1)) imshow(z,interpolation='nearest') show() and both the imshow() and contour() commands do nicely their job, but the scalar z is defined on a trivial rectangular domain and represented as a 2D array. In my problem I have: 1) a set of couples (theta,r) specifying a list of positions on a tube cross-section. 2) for each (theta,r) couple, I have a single value of T (which is thus a long 1D array). In general, (theta,r) may be two coordinates given on a non-trivial domain and I have a scalar specified for each couple I thus form. Both contour and imshow complain because they expect a 2D array. I am sorry if I am struggling over some triviality, but I am not making much progress by myself. Many thanks Lorenzo On 26/06/07, Brian wrote: > It sounds to me that you want to have a contour plot which takes as input > the r,theta, and T. I would suggest just > > > On 6/26/07, Lorenzo Isella < lorenzo.isella@...> wrote: > > > > Hello, > > Thanks for your suggestion, but I still have a problem. > > Maybe I did not make myself clear (or most likely I have a problem > > about how to implement your suggestion): actually I have T=T(r,theta) > > and I would like to make a 2D plot using colors such that one can see > > that the domain where I am plotting is actually a circle. > > The example I mentioned is not exactly what I need since there one can > > find how to plot in polar coordinates a function of r alone. > > Furthermore, I do not have necessarily an equally spaced grid. > > For instance, let me consider the case of 5 theta's and 7 radial > > position and consequentely 35 values of T: > > > > theta R > > T > > 0.000000000000000000e+00 0.000000000000000000e+00 5.459815003314423620e+01 > > 0.000000000000000000e+00 1.666666666666666574e-01 4.853828855239110851e+01 > > 0.000000000000000000e+00 3.333333333333333148e-01 4.315101251901344881e+01 > > 0.000000000000000000e+00 5.000000000000000000e-01 3.836167151642037965e+01 > > 0.000000000000000000e+00 6.666666666666666297e-01 3.410390059527122020e+01 > > 0.000000000000000000e+00 8.333333333333332593e-01 3.031870066752165016e+01 > > 0.000000000000000000e+00 1.000000000000000000e+00 2.695362096775039973e+01 > > 1.570796326794896558e+00 0.000000000000000000e+00 2.396203225329512776e+01 > > 1.570796326794896558e+00 1.666666666666666574e-01 2.130248067207563523e+01 > > 1.570796326794896558e+00 3.333333333333333148e-01 1.893811334477913277e+01 > > 1.570796326794896558e+00 5.000000000000000000e-01 1.683616770181326316e+01 > > 1.570796326794896558e+00 6.666666666666666297e-01 1.496751749887080329e+01 > > 1.570796326794896558e+00 8.333333333333332593e-01 1.330626922033307302e+01 > > 1.570796326794896558e+00 1.000000000000000000e+00 1.182940327795447999e+01 > > 3.141592653589793116e+00 0.000000000000000000e+00 1.051645503298913731e+01 > > 3.141592653589793116e+00 1.666666666666666574e-01 9.349231221746512333e+00 > > 3.141592653589793116e+00 3.333333333333333148e-01 8.311557855141172624e+00 > > 3.141592653589793116e+00 5.000000000000000000e-01 7.389056098930650407e+00 > > 3.141592653589793116e+00 6.666666666666666297e-01 6.568943029058285532e+00 > > 3.141592653589793116e+00 8.333333333333332593e-01 5.839854501207304871e+00 > > 3.141592653589793116e+00 1.000000000000000000e+00 5.191687680104649871e+00 > > 4.712388980384689674e+00 0.000000000000000000e+00 4.615461046534314882e+00 > > 4.712388980384689674e+00 1.666666666666666574e-01 4.103189942205120566e+00 > > 4.712388980384689674e+00 3.333333333333333148e-01 3.647775927922803252e+00 > > 4.712388980384689674e+00 5.000000000000000000e-01 3.242908421924544982e+00 > > 4.712388980384689674e+00 6.666666666666666297e-01 2.882977255397825012e+00 > > 4.712388980384689674e+00 8.333333333333332593e-01 2.562994933482758420e+00 > > 4.712388980384689674e+00 1.000000000000000000e+00 2.278527524544009530e+00 > > 6.283185307179586232e+00 0.000000000000000000e+00 2.025633220058637107e+00 > > 6.283185307179586232e+00 1.666666666666666574e-01 1.800807713756398032e+00 > > 6.283185307179586232e+00 3.333333333333333148e-01 1.600935643142084031e+00 > > 6.283185307179586232e+00 5.000000000000000000e-01 1.423247420534685892e+00 > > 6.283185307179586232e+00 6.666666666666666297e-01 1.265280855439646635e+00 > > 6.283185307179586232e+00 8.333333333333332593e-01 1.124847036463023642e+00 > > 6.283185307179586232e+00 1.000000000000000000e+00 1.000000000000000000e+00 > > > > > > > > How would you plot them in order to have a 2D-color plot where one can > > understand we are working on a circle (well, maybe it will look like > > something different since I have only a few grid points, but the aim > > is clear, I hope)? > > Kind Regards > > > > Lorenzo ```
 Re: [Matplotlib-users] 2D Radial Plots From: Andrew Straw - 2007-06-26 18:12:18 ```Can you convert your radial coordinates to Cartesian coordinates and use approach #2 here: http://scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data Lorenzo Isella wrote: > Hello, > Sorry for this tread getting quite long, but I am not getting there yet. > Online I found examples like: > > ```