Re: [Matplotlib-users] Axes Scaling
Hi François, Why would it be a waste to multiply the values in an array by the scaling factors? Can you provide an example of your code so everybody can get a better idea of what you're doing now? Thanks, Alexa On Fri, Feb 17, 2012 at 9:07 AM, Francois Lemery francois.lem...@gmail.comwrote: Hi Python World! I currently have a 2D array: A[i][j] which I can plot very nicely using the contourf function. However, in this plot, the axes span from (0, i) and (0, j). I would like to multiply each axes by a scaling constant- thereby turning the array element values into physical quantities (distance and time for example). Could anyone help me with this? I've looked around, but so far the only solution I have found is to create a new set of arrays with these scaling factors included. I can do this, but I feel as though it would be a waste. -- Thanks! François -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Labeling Contours
Hi Everybody, I'm trying to label the contours of my contour plot following this example - http://matplotlib.sourceforge.net/examples/pylab_examples/contour_label_demo.html My actual code looks like this - import matplotlib matplotlib.use('PDF') from pylab import * import numpy as np # Define the surface of the plot metals=np.arange(-3.0, 1.1, 0.1) U=np.arange(-6.0, 0.25, 0.25) # Create the arrays that the data will be stored in o3=np.zeros([25,41]) o2=np.zeros([25,41]) c3=np.zeros([25,41]) mg2=np.zeros([25,41]) c3=np.zeros([25,41]) si2=np.zeros([25,41]) s3=np.zeros([25,41]) CS=plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig], alpha=0.50, colors='#f88534') CS=plt.contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig], alpha=0.50, colors='#f2f34f') CS=plt.contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig], alpha=0.50, colors='#93d3f3') CS=plt.contourf(metals, U, mg2, levels=[mg2col-nsig*mg2sig, mg2col+nsig*mg2sig], alpha=0.50, colors='#ff536d') CS=plt.contourf(metals, U, s3, levels=[s3col-nsig*s3sig, s3col+nsig*s3sig], alpha=0.50, colors='#83c460') CS=plt.contourf(metals, U, si2, levels=[si2col-nsig*si2sig, si2col+nsig*si2sig], alpha=0.50, colors='black') # Trying to label the contours fmt = {} strs = [ 'O III', 'O II', 'C III', 'Mg II', 'S III', 'Si II'] for l,s in zip(levels, strs): fmt[l] = s plt.clabel(CS,levels[::2],inline=True,fmt=fmt,fontize=14) But I get an error that says that levels is not defined. What should I do? Thanks! Alexa -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Labeling Contours
Hi Eric, Thanks for your help, I'm still really new to python and matplotlib. I've got my labels defined but now I'm having another problem with the formatting. I'm doing - CS1.level=[14.07, 14.27] plt.clabel(CS1,CS1.level[::2],inline=True,fmt='OIII',fontize=14) Where I get a type error that says that not all string arguments are getting converted during formatting. This is the full error, Traceback (most recent call last): File ContourAttempt.py, line 81, in module plt.clabel(CS1,CS1.level[::2],inline=True,fmt='OIII',fontize=14) # Something wrong with formmating File /Users/alexavillaume/src/matplotlib/lib/matplotlib/pyplot.py, line 2176, in clabel ret = ax.clabel(CS, *args, **kwargs) File /Users/alexavillaume/src/matplotlib/lib/matplotlib/axes.py, line 7326, in clabel return CS.clabel(*args, **kwargs) File /Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py, line 217, in clabel self.labels(inline,inline_spacing) File /Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py, line 624, in labels lw = self.get_label_width(lev, self.labelFmt, fsize) File /Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py, line 284, in get_label_width lev = self.get_text(lev, fmt) File /Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py, line 344, in get_text return fmt%lev TypeError: not all arguments converted during string formatting On Wed, Feb 15, 2012 at 10:34 AM, Eric Firing efir...@hawaii.edu wrote: On 02/15/2012 10:15 AM, Alexa Villaume wrote: Hi Everybody, I'm trying to label the contours of my contour plot following this example - http://matplotlib.sourceforge.net/examples/pylab_examples/contour_label_demo.html My actual code looks like this - import matplotlib matplotlib.use('PDF') frompylab import* import numpy as np # Define the surface of the plot metals=np.arange(-3.0, 1.1, 0.1) U=np.arange(-6.0, 0.25, 0.25) # Create the arrays that the data will be stored in o3=np.zeros([25,41]) o2=np.zeros([25,41]) c3=np.zeros([25,41]) mg2=np.zeros([25,41]) c3=np.zeros([25,41]) si2=np.zeros([25,41]) s3=np.zeros([25,41]) CS=plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig], alpha=0.50, colors='#f88534') CS=plt.contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig], alpha=0.50, colors='#f2f34f') CS=plt.contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig], alpha=0.50, colors='#93d3f3') CS=plt.contourf(metals, U, mg2, levels=[mg2col-nsig*mg2sig, mg2col+nsig*mg2sig], alpha=0.50, colors='#ff536d') CS=plt.contourf(metals, U, s3, levels=[s3col-nsig*s3sig, s3col+nsig*s3sig], alpha=0.50, colors='#83c460') CS=plt.contourf(metals, U, si2, levels=[si2col-nsig*si2sig, si2col+nsig*si2sig], alpha=0.50, colors='black') # Trying to label the contours fmt = {} strs = [ 'O III', 'O II', 'C III', 'Mg II', 'S III', 'Si II'] for l,s in zip(levels, strs): fmt[l] = s plt.clabel(CS,levels[::2],inline=True,fmt=fmt,fontize=14) But I get an error that says that levels is not defined. What should I do? Define levels! In your call to clabel, you are referencing a global levels which you did not define; what you did define is the levels attribute of each CS object. So probably what you want is something like: plt.clabel(CS, CS.levels[::2],inline=True,fmt=fmt,fontize=14) but you need one such call for each CS you create, if you want all of them labeled. Eric Thanks! Alexa -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223
Re: [Matplotlib-users] Colobar and change axis x and y labels
Try using 'xticks' and 'yticks', those commands let you define the location and label fo your tick marks. Example - xticks( arange(5), ('0', '100', '200', '300', '400') ) Where the argument in arange is the number of tick labels you're making On Wed, Feb 15, 2012 at 10:56 AM, pythp...@root-1.de wrote: Hello, I don't know if I can ask questions concerning matplotlib problems in this email list ... just let me know that this is not the right place, if. I have an image, which I can read and put into a figure. The image has axis and I can even save the image. I have two issues: 1. Since it is an 512 x 512 pixel image, the x and y axis labels go from 0 to 500. However, I don't want these labels, I want to change them to, e.g., 0 .. 3400 and 0 .. 3400. How can I do this? 2. I tried to attach a color bar to the right of the image but without success. Have you a hint? The code can be found below, it is a rather simple one. Thanks in advance for any help. Pythphys. * import scipy import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np file_path = path_to_file # The binary file is read data = scipy.fromfile(file=file_path,dtype=scipy.int16) data = data.byteswap() # The file has 512 x 512 pixel data.shape = 512, 512 # The following code works fine. However, I still need: # # - Color bar (plt.color() does not work) # - The x and y labels are 0 ... 500 and 0 ... 500 = I want to change these labels. How. fig = plt.figure() frame = plt.subplot(111) frame.imshow(data) frame.axis() plt.xlabel('X (nm)') plt.ylabel('Y (nm)') plt.savefig(image) -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fwd: Re: Colobar and change axis x and y labels
You need to use the 'imshow' function to display an image in greyscale. You have to turn your image into an array of values and then put that array into imshow with the colormap set to grey. I don't know about how to do a plane fit... On Wed, Feb 15, 2012 at 9:18 PM, pythp...@root-1.de wrote: Thanks Alexa and Jerzy. other questions? ... Here they are: - changing to an image grey scale only needs ... what? - I need to do a 'plane fit' of the image. Does matplotlib have some routine for this? Or shall I use other math libs? Thanks again. Le 16/02/2012 02:20, Alexa Villaume a écrit : Try using 'xticks' and 'yticks', those commands let you define the location and label fo your tick marks. This *alone* will not do, the image might be scaled badly. Add extent. Try this: fig = plt.figure() frame = plt.subplot(111) im=frame.imshow(data,extent=[0,3400,0,3400]) plt.xticks([0,3400]); plt.yticks([0,3400]) plt.xlabel('X (nm)') plt.ylabel('Y (nm)') plt.colorbar(im) plt.show() == Jerzy Karczmarczuk Caen, France -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] I cannot download the matplotlib
Hi Fadhah, This is the tutorial I used to install matplotlib on my computer and it was really easy to understand and follow the steps - http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ If that doesn't help with your problems describe what they are more specifically and you'll be able to get better help Cheers, Alexa On Sun, Feb 12, 2012 at 5:39 PM, love ali a.fa...@yahoo.com wrote: Dear all, I use the mac OS X 10.6.8 and I try to install the matplotlib but I cannot run it in my computer so could you please help me? Thanks, Fadhah -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] I cannot download the matplotlib
Hi, 1.) For terminal just go to your finder and type in terminal in the search bar, terminal should pop up 2.) I don't think you do, you might need to change the path variable to point to the python you have. There are instructions for that in the tutorial I linked to. 3.) I'm not sure what you're asking 4.) What do you mean you can't find them on your computer? Start a terminal window and type 'python' This should bring you to the interactive python environment. Then type, 'import numpy' Does it successfully import or do you get an error message? (Also, click Reply All to keep this conversation to the list - Alexa On Mon, Feb 13, 2012 at 10:11 AM, a.fa...@yahoo.com wrote: Hi Alex , thank you so much for your help. I have some questions: 1- where can I find the terminal in my computer 2- I have already had python 2.6.6 so do I need to delete it and start again. 3- my mac is os x 10.6.8 so do I need to clean it while it is already do not have much download. 4- I download the scipy ,numpy and i have these modules successfully installed but I cannot find them in my computer. So could you help me ? Many thanks, Fadh من جهاز الـ iPhone الخاص بي في 14/02/2012، الساعة 5:04 AM، كتب Alexa Villaume alexa7...@gmail.com: Hi Fadhah, This is the tutorial I used to install matplotlib on my computer and it was really easy to understand and follow the steps - http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ If that doesn't help with your problems describe what they are more specifically and you'll be able to get better help Cheers, Alexa On Sun, Feb 12, 2012 at 5:39 PM, love ali a.fa...@yahoo.com a.fa...@yahoo.com wrote: Dear all, I use the mac OS X 10.6.8 and I try to install the matplotlib but I cannot run it in my computer so could you please help me? Thanks, Fadhah -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list 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 -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Alpha keyword not working with contourf
(Sorry about not replying to list before. I usually have to be pretty vigilant about not clicking Reply-All) I made my figure a pdf and the transparency works fine. So thanks! Just another quick question is it the Postscript language itself that doesn't support transparency or the way mpl handles postscript files? On Sat, Feb 11, 2012 at 10:48 AM, Eric Firing efir...@hawaii.edu wrote: On 02/11/2012 10:30 AM, Alexa Villaume wrote: Thanks for replying Eric. (You're welcome. But please keep replies on the list when they are potentially useful to others, as yours is.) Here is my minimal script - import matplotlib frompylab import* import numpy as np importos metals=np.arange(-3.0, 1.1, 0.1) U=np.arange(-6.0, 0.25, 0.25) o3=np.zeros([25,41]) plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig], alpha=0.20, colors='blue') plt.savefig(CoutourPlot.ps) The Postscript language does not support transparency, so transparency is lost when you use the mpl postscript backend. The way to work around this, if you really need to end up with a postscript file, is to save the file as pdf, and then use a converter program to render that as postscript. (It might be a print-to-file or save-as option on your pdf display program, for example. I don't know what is typically available on a Mac, but Macs have long been pdf-friendly. In general, the need for ps files has been diminishing. I almost never generate them any more.) Eric It plots fine except except there is no transparency in colors of the contour, it's like alpha is always set to 1.0 On Sat, Feb 11, 2012 at 8:23 AM, Eric Firing efir...@hawaii.edu mailto:efir...@hawaii.edu wrote: On 02/11/2012 07:40 AM, Alexa Villaume wrote: Hi All, I'm just getting started with matplotlib. I'm trying to make a contour plot using contourf and have the different paths colored and semi transparent but the alpha keyword doesn't seem to do anything. I googled around and found that other people have had this same problem but I didn't find a solution. Here's what I'm doing - contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig], alpha=0.20, colors='magenta') contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig], alpha=0.20, colors='blue') contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig], alpha=0.20, colors='green') To plot them all together. For reference my machine is running Mac OS X 10.6.8 and my version of matplotlib is 1.2.x Thanks! Please provide a minimal but complete script that illustrates the problem; describe what it is in the output that does not match your expectations. e.g., import numpy as np import matplotlib.pyplot as plt z = np.arange(20).reshape(4,5) plt.contourf(z, levels=[2,3], alpha=0.2, colors='magenta') plt.savefig(testcontourf_**alpha.png) which produces a pale magenta stripe, as expected, with mpl from github master. Eric -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Alpha keyword not working with contourf
Hi All, I'm just getting started with matplotlib. I'm trying to make a contour plot using contourf and have the different paths colored and semi transparent but the alpha keyword doesn't seem to do anything. I googled around and found that other people have had this same problem but I didn't find a solution. Here's what I'm doing - contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig], alpha= 0.20, colors='magenta') contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig], alpha= 0.20, colors='blue') contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig], alpha= 0.20, colors='green') To plot them all together. For reference my machine is running Mac OS X 10.6.8 and my version of matplotlib is 1.2.x Thanks! -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Trouble with reading 2d array
Hi there, I have a 2d array that I'd like to contour. The plot isn't turning out right and I think it's because the array isn't be read in correctly. It's a 25x41 array that is in a text file. I have tried using genfromtxt and the asciitable module to read the data in and neither gives the correct output. Does anyone know of any command either specific for reading in 2d arrays or is able to handle 2d arrays? Thanks, Alexa -- Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free Love Thy Logs t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Defining coordinates for contour plot
Hello, I'm trying to make a contour plot and I'm running into problems when specifying the coordinates for the plot. I do, #Specify coordinates of the surface delta0=1.0 delta1=0.1 x=np.arange(0.0, 6.0, delta0) y=np.arange(-1.0,3.0, delta1) #Contour the arrays. plt.contour(x, y, O3, O3Level) And I get an error that says, TypeError: Length of x must be number of columns in z, and length of y must be number of rows. I don't understand how I'm supposed to get the coordinates for the plot that I want and make x and y the same shape as z. Any suggestions? Thanks, Alexa -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users