[Matplotlib-users] Adding Arrows to polar plots
Hi all, what is the native data coordinate system for Arrows in a polar plot ? How do I add arrows to a polar plot ? An example would be appreciated. fig = figure(figsize=(12,12)) ax = fig.add_subplot(111, polar=True) Nils -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Creating a new colormap based on a cmap from matplotlib.cm?
+ Keith Hughitt -+ Hi all, Does anyone know of a good way to create a new LinearSegmentedColormap based off an existing one? I have a function which attempts to generate N optimal color map indices for a given data array. In cases where the number of values specified in _segmentdata is the same as N, then I can simply copy _segmentdata and modify the indices and create a new color map. In many cases, however, the segment data has far fewer interpolation points, e.g.: In [52]: cm.gray._segmentdata Out[52]: {'blue': ((0.0, 0, 0), (1.0, 1, 1)), 'green': ((0.0, 0, 0), (1.0, 1, 1)), 'red': ((0.0, 0, 0), (1.0, 1, 1))} Other colormaps may have an arbitrary number of interpolation points. Ideally, what I would like is a way to expand this into N points (e.g. 256) so that I use that as input for my new map. i cannot really help you with your approach, but i also think it's not so elegant to expand cmaps. did you try to understand the way cmaps can be defined by gradient borders? - http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps i.e. a friend gave me a colormap defined by points and i converted it to something like that (by just looking at the colors): ie_data = { 'red': ((0.00, 0.357, 0.357), (0.50, 1.000, 1.000), (0.75, 1.000, 1.000), (1.00, 1.000, 1.000)), 'green':((0.00, 0.467, 0.467), (0.50, 1.000, 1.000), (0.75, 0.750, 0.750), (1.00, 0.371, 0.371)), 'blue':((0.00, 0.800, 0.800), (0.50, 1.000, 1.000), (0.75, 0.157, 0.157), (1.00, 0.157, 0.157)) } ie = matplotlib.colors.LinearSegmentedColormap('ieMap', ie_data, 256) use it with cmap=ie regards -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] memory error - netcdf plots
On 10/12/11 8:20 PM, questions anon wrote: Hi All, I keep receiving a memory error when processing many netcdf files. I assumed it had something to do with how I loop things and maybe needed to close things off properly but I recently received an error that made me think it might be because of matplotlib. In the code below I am looping through a bunch of netcdf files (each file is hourly data for one month) and within each netcdf file I am outputting a *png file every three hours. This works for one netcdf file (therefore one month) but when it begins to process the next netcdf file I receive a memory error (see below). Since I have tidied some of my code up it seems to process partly into the second file but then I still receive the memory error. I have tried a few suggestions such as: -Combining the dataset using MFDataset (using NETCDF4) is not an option because the files do not have unlimited dimension. - gc.collect() but that just results in a /GEOS_ERROR: bad allocation error/. -only open LAT and LON once (which worked) System Details: Python 2.7.2 |EPD 7.1-2 (32-bit)| (default, Jul 3 2011, 15:13:59) [MSC v.1500 32 bit (Intel)] on win32 Any feedback will be greatly appreciated as I seem to keep ending up with memory errors when working with netcdf files this even happens if I am using a much better computer. *Most recent error: * Traceback (most recent call last): File C:\plot_netcdf_merc_multiplot_across_multifolders_TSFC.py, line 78, in module plt.savefig((os.path.join(outputfolder, 'TSFC'+date_string+'UTC.png'))) File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 363, in savefig return fig.savefig(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\figure.py, line 1084, in savefig self.canvas.print_figure(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\backends\backend_wxagg.py, line 100, in print_figure FigureCanvasAgg.print_figure(self, filename, *args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\backend_bases.py, line 1923, in print_figure **kwargs) File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 438, in print_png FigureCanvasAgg.draw(self) File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 393, in draw self.renderer = self.get_renderer() File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 404, in get_renderer self.renderer = RendererAgg(w, h, self.figure.dpi) File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 59, in __init__ self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False) RuntimeError: Could not allocate memory for image *Error when I added gc.collect()* GEOS_ERROR: bad allocation *Old error (before adding gc.collect() )* /Traceback (most recent call last): File d:/plot_netcdf_merc_multiplot_across_multifolders__memoryerror.py, line 44, in module TSFC=ncfile.variables['T_SFC'][1::3] File netCDF4.pyx, line 2473, in netCDF4.Variable.__getitem__ (netCDF4.c:23094) MemoryError/ from netCDF4 import Dataset import numpy as N import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap from netcdftime import utime from datetime import datetime import os import gc shapefile1=E:/ griddeddatasamples/GIS/DSE_REGIONS MainFolder=rE:/griddeddatasamples/GriddedData/InputsforValidation/T_SFC/ OutputFolder=rE:/griddeddatasamples/GriddedData/OutputsforValidation fileforlatlon=Dataset(E:/griddeddatasamples/GriddedData/InputsforValidation/T_SFC/TSFC_1974_01/IDZ00026_VIC_ADFD_T_SFC.nc, 'r+', 'NETCDF4') LAT=fileforlatlon.variables['latitude'][:] LON=fileforlatlon.variables['longitude'][:] for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: print dir path=path+'/' for ncfile in files: if ncfile[-3:]=='.nc': print dealing with ncfiles:, ncfile ncfile=os.path.join(path,ncfile) ncfile=Dataset(ncfile, 'r+', 'NETCDF4') TSFC=ncfile.variables['T_SFC'][1::3] TIME=ncfile.variables['time'][1::3] ncfile.close() gc.collect() for TSFC, TIME in zip((TSFC[:]),(TIME[:])): cdftime=utime('seconds since 1970-01-01 00:00:00') ncfiletime=cdftime.num2date(TIME) print ncfiletime timestr=str(ncfiletime) d = datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') date_string = d.strftime('%Y%m%d_%H%M') map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33, llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i') x,y=map(*N.meshgrid(LON,LAT)) map.drawcoastlines(linewidth=0.5)
Re: [Matplotlib-users] key_press_event weirdness
Benjamin Root ben.root@... writes: Which backend and platform are you using?Ben Root I run Arch Linux x86_64 and I am using the GTKAgg backend. I tried both with IPython and python directly (2.7.2). jorges -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] key_press_event weirdness
On Fri, Oct 14, 2011 at 7:18 AM, Jorge Scandaliaris jorgesmbox...@yahoo.es wrote: I run Arch Linux x86_64 and I am using the GTKAgg backend. I tried both with IPython and python directly (2.7.2). I am not seeing this on Linux x86_64 with backend GTKAgg version 2.22.0 on python 2.7. Eg, if I run: python simple_plot.py -dgtkagg and then hover over the axes window (w/o clicking on it but the window has the focus on hover) and press 'g') the grids is toggled. JDH -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] key_press_event weirdness
John Hunter jdh2358@... writes: I am not seeing this on Linux x86_64 with backend GTKAgg version 2.22.0 on python 2.7. Eg, if I run: python simple_plot.py -dgtkagg and then hover over the axes window (w/o clicking on it but the window has the focus on hover) and press 'g') the grids is toggled. JDH You're right, John, it works here too with the gtkagg backend. I have just noticed that I had different backend options set in matplotlib.conf and matplotlibrc. My initial report refers then to the Qt4Agg backend. BTW, which of matplotlib.conf or matplotlibrc is preferred? jorges -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] key_press_event weirdness
On Fri, Oct 14, 2011 at 8:52 AM, John Hunter jdh2...@gmail.com wrote: On Fri, Oct 14, 2011 at 8:46 AM, Jorge Scandaliaris jorgesmbox...@yahoo.es wrote: You're right, John, it works here too with the gtkagg backend. I have just noticed that I had different backend options set in matplotlib.conf and matplotlibrc. My initial report refers then to the Qt4Agg backend. OK, I can confirm this too on Qt4Agg version 4.8.3. I opened an issue here https://github.com/matplotlib/matplotlib/issues/525 I am no qt expert so perhaps someone else can suggest a solution. In the gtk backend, I believe we added: self.canvas.grab_focus() to support events w/o clicking on the canvas. -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] how to make x and y axis equal distance in ticks
Dear all, I am trying to plot data on a 1:1 ratio plot to compare the data. I can set the x and y aixs to have the same limits. but how can I set them to have the same distance between ticks in the graph? Thanks a lot, chao -- *** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to make x and y axis equal distance in ticks
On Fri, Oct 14, 2011 at 12:24 PM, Chao YUE chaoyue...@gmail.com wrote: Dear all, I am trying to plot data on a 1:1 ratio plot to compare the data. I can set the x and y aixs to have the same limits. but how can I set them to have the same distance between ticks in the graph? Thanks a lot, chao Set the aspect ratio to be equal: ax.plot(x, y) ax.set_aspect('equal') I hope that helps! Ben Root -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] custom axis range
Hello, I have a question regarding setting a custom axis range. Here's a basic example: import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot([1,2,3]) ax.axis([xmin,xmax,ymin,ymax]) plt.show() Now the question that I'm having is the following. The way I understand it now, I either have to live with the default axis ranges which matplotlib gives me, or I need to change all four values xmin, xmax, ymin, ymax using the ax.axis command. Say that I'm happy with xmin, ymin and ymax, and I only want to set xmax to a value slightly larger than the default. Is there a way to specify just that and to be able to keep the other three? The command which I'm looking for would be something like: ax.axis([keep default, xmax, keep default, keep default]) If someone has a suggestion, I would be very grateful. Thanks in advance! -- View this message in context: http://old.nabble.com/custom-axis-range-tp32655869p32655869.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] question about tight_layout()
Just trying out the latest mpl 1.1.0 and the tight_layout() method. I saw the guide written about it, but am a unsure how to use this when using the OO approach to using Matplotlib. When using pyplot, the method is: plt.tight_layout(). When using the OO form of mpl, is it: figure.tight_layout() ? I assume it is, because I tried this and it didn't give me a name error, but I did get an error: ValueError: left cannot be = right. What am I doing wrong? Thanks, Che -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] custom axis range
On Friday, October 14, 2011, jopeto g_nikifo...@hotmail.com wrote: Hello, I have a question regarding setting a custom axis range. Here's a basic example: import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot([1,2,3]) ax.axis([xmin,xmax,ymin,ymax]) plt.show() Now the question that I'm having is the following. The way I understand it now, I either have to live with the default axis ranges which matplotlib gives me, or I need to change all four values xmin, xmax, ymin, ymax using the ax.axis command. Say that I'm happy with xmin, ymin and ymax, and I only want to set xmax to a value slightly larger than the default. Is there a way to specify just that and to be able to keep the other three? The command which I'm looking for would be something like: ax.axis([keep default, xmax, keep default, keep default]) If someone has a suggestion, I would be very grateful. Use ax.set_xlim() and it's y-axis equivalent. You can even use kwargs to those functions to manually set only one of the two limits. Ben Root -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users