[Matplotlib-users] matplotlib - image size issue
Hi, I am trying to create a chart using a given file as background, drawing some curves on the map, and saving an 800x600 PNG. Code Snipet: map = Basemap( ) pilImg=Image.open('mybkgmap.gif') rgba = pil_to_array(pilImg) map.imshow(rgba,interpolation='nearest') # showing background map . # Plot some paths on top of background maps # Add some text explaining map symbols (plt.gcf()).set_size_inches(8,6) (plt.gcf()).set_dpi(100) plt.savefig('my.png',format='PNG',bbox_inches='tight',pad_inches=0) # Obtain an 620x480 image without a border plt.savefig('my.png',format='PNG') # Obtain an 800x600 image with a white border I don't want Any idea on how can I get the 800x600 without the white border? Any hint will be appreciated. Thank you -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] finding the bounding box of an arbitrary artist
I'm wanting to highlight the artist under the cursor with a transparent Rectangle patch. To do this, I have very, roughly, in a mouse motion handler, under = self.figure.hitlist(ev) if under: artist = under[0] bbox = artist.get_window_extent() highlight = matplotlib.patches.Rectangle(xy=bbox.min,width=bbox.width,height=bbox.height,alpha=0.2,color='yellow') # further code to blit the last captured graph region with highlight drawn on top The main problem is that all artists don't implement get_window_extent(); a Text object does, and a legend object does, but the Axis objects do not. So is there a general way to get the bounding box of an artist? I looked through the API and didn't see anything there. I thought this would be easy to get to, since almost (every?) artist implements contains(). But it looks like in the case of XAxis, anyway, that the "hitbox" is being calculated on the fly in XAxis.contains(). -- Daniel Hyams dhy...@gmail.com -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Setting boxplot confidence intervals manually
Hey folks, I'm working on a patch to axes.boxplot that will allow the user to manually specify the median and confidence intervals (notches) on a boxplot. My need for this arises since I compute the notch locations using the BCa-method, which depends on Scipy. My question relates to how to best have users input their predefined median and its confidence interval. In my use case, I'm always calling boxplot one data set at a time and so it has made sense for me pass the values as a dictionary to my locally-modified boxplot function. This is probably a quite unique use case. In the more general use case where an arbitrary number of boxplots will be generated on a single axes object, what would be the best method of input? My initial though is to specify a list-of-tuples in the form: [(lower1, median1, upper1), (lower2, median2, upper2), ..., (lowerN, medianN, upperN)]. The modified function signature would be: def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None, patch_artist=False, bootstrap=None, manualVals=None): The other best option that comes to mind would be to pass each value as an individual numpy array with dimensions that are compatible with the data (x), i.e., def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None, patch_artist=False, bootstrap=None, lowerCIs=None, medians=None, upperCIs=None): This seems a bit cumbersome both to use and implement, though quite flexible as the user would not be forced to supply all three arrays. Any advice, requests, or general input would be much appreciated. Cheers, -Paul H. -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib window layout questions
Hello, I have two questions regarding to the positioning of a mpl window (using WXAgg backend) 1-) How to create a maximized window, instead of me clicking on window to maximize it each time? 2-) I have two screens. Interestingly, my mpl windows tend to open on my small screen. How can I force mpl/ipython/WX/X-windows to open mpl windows on my 2nd and bigger monitor? Thanks. -- Gökhan -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to get log axes for a density plot with matplotlib?
I am trying to make a 2D density plot (from some simulation data) with matplotlib. My x and y data are defined as the log10 of some quantities. How can I get logarithmic axes (with log minor ticks)? Here is an exemple of my code: import numpy as np import matplotlib.pyplot as plt Data = np.genfromtxt("data") # A 2-column data file x = np.log10(Data[:,0]) y = np.log10(Data[:,1]) xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() fig = plt.figure() ax = fig.add_subplot(111) hist = ax.hexbin(x,y,bins='log', gridsize=(30,30), cmap=cm.Reds) ax.axis([xmin, xmax, ymin, ymax]) plt.savefig('plot.pdf') -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib-1.0.1 with Python 2.7.2 build error
Dear Users, I am trying to add module matplotlib-1.0.1 to my Python 2.7.2 on an IBM power6 with Aix 5.3 . I get the below error when I issue the command python setip.py build did any one faced same issue or can I get any expert suggestion for fixing this issue. with best regards, Sudheer xlc++ xlc -bI:/gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp build/temp.aix-5.3-2.7/src/ft2font.o build/temp.aix-5.3-2.7/src/mplutils.o build/temp.aix-5.3-2.7/CXX/cxx_extensions.o build/temp.aix-5.3-2.7/CXX/cxxsupport.o build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o build/temp.aix-5.3-2.7/CXX/cxxextensions.o -L/opt/freeware/lib -L/usr/local/lib -lfreetype -lz -lstdc++ -lm -o build/lib.aix-5.3-2.7/matplotlib/ft2font.so sjo@f2n1login1>xlc++ -bI:/gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp build/temp.aix-5.3-2.7/src/ft2font.o build/temp.aix-5.3-2.7/src/mplutils.o build/temp.aix-5.3-2.7/CXX/cxx_extensions.o build/temp.aix-5.3-2.7/CXX/cxxsupport.o build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o build/temp.aix-5.3-2.7/CXX/cxxextensions.o -L/opt/freeware/lib -L/usr/local/lib -lfreetype -lz -lstdc++ -lm -o build/lib.aix-5.3-2.7/matplotlib/ft2font.so ld: 0711-317 ERROR: Undefined symbol: .main ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. i compiled with -bnoquiet option and get below details (ld): setopt 64 (ld): halt 4 (ld): setfflag 4 (ld): savename build/lib.aix-5.3-2.7/matplotlib/ft2font.so (ld): filelist 15 2 (ld): i /lib/crt0_64.o (ld): i build/temp.aix-5.3-2.7/src/ft2font.o (ld): i build/temp.aix-5.3-2.7/src/mplutils.o (ld): i build/temp.aix-5.3-2.7/CXX/cxx_extensions.o (ld): i build/temp.aix-5.3-2.7/CXX/cxxsupport.o (ld): i build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o (ld): i build/temp.aix-5.3-2.7/CXX/cxxextensions.o (ld): lib /opt/freeware/lib/libfreetype.a (ld): lib /opt/freeware/lib/libz.a (ld): lib /opt/freeware/lib/libstdc++.a (ld): lib /usr/lib/libm.a (ld): lib /usr/vac/lib/libxlopt.a (ld): lib /usr/vac/lib/libxl.a (ld): lib /usr/vacpp/lib/libC.a (ld): lib /usr/lib/libc.a LIBRARY: Shared object libfreetype.a[libfreetype.so.6]: 343 symbols imported. LIBRARY: Shared object libz.a[libz.so.1]: 72 symbols imported. LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr_32.imp]: 0 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr2_32.imp]: 0 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr3_32.imp]: 0 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[ansi_32.imp]: 0 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr_64.imp]: 383 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr2_64.imp]: 24 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[shr3_64.imp]: 27 LIBRARY: Symbols imported from import file /usr/vacpp/lib/libC.a[ansi_64.imp]: 2448 LIBRARY: Shared object libC.a[ansi_64.o]: 2658 symbols imported. LIBRARY: Shared object libc.a[shr_64.o]: 2669 symbols imported. LIBRARY: Shared object libc.a[posix_aio_64.o]: 20 symbols imported. LIBRARY: Shared object libc.a[aio_64.o]: 18 symbols imported. LIBRARY: Shared object libc.a[pse_64.o]: 5 symbols imported. LIBRARY: Shared object libc.a[dl_64.o]: 4 symbols imported. LIBRARY: Shared object libc.a[pty_64.o]: 1 symbols imported. FILELIST: Number of previously inserted files processed: 15 (ld): imports /gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp IMPORTS: Symbols imported from import file /gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp: 1206 (ld): resolve RESOLVE: 63 of 18106 symbols were kept. (ld): addgl /usr/lib/glink64.o ADDGL: Glink code added for 11 symbols. (ld): er full ld: 0711-318 ERROR: Undefined symbols were found. The following symbols are in error: SymbolInpndx TY CL Source-File(Object-File) OR Import-File{Shared-object} RLD: Address Section Rld-type Referencing Symbol -- .main [10]ER PR crt0_64.s(/lib/crt0_64.o) 0098 .textR_RBR[34] .__start ER: The return code is 8. ld: 0711-317 ERROR: Undefined symbol: .main -- with best regards Sudheer ** Sudheer Joseph Scientist INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS) MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA "OCEAN VALLEY" PRAGATHI NAGAR (BO) OPP.JNTU, NIZAMPET SO Andhra Pradesh, India. PIN- 500 090. TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile) Tel:+91-40-23886047(O),Fax:+91-40-23892910(O) E-mail: sudheer.jos...@yahoo.com; s...@incois.gov.in. Web- http://oppamthadathil.tripod.com --* --- "The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challen
[Matplotlib-users] Making copies of figures and selectively writing them to a multipage PDF
Hi, I am attempting to build a set of Figure objects (based on matplotlib.figure) which are essentially the same chart with different x-axis limits. I would like to do this in a function that returns the figures in a list so that i can choose to write some or all of the figures to a multipage PDF at a later date. I attempted to do the following: import matplotlib.figure as fig from matplotlib.backends.backend_pdf import PdfPages, FigureCanvasPdf xdata = [1,2,3,4,5] ydata = [5,4,3,2,1] fig1 = fig.Figure(figsize=(2,2)) ax1 = fig.Figure.add_subplot(fig1,111) ax1.plot(xdata,ydata) figures = [] ax1.set_xlim([0,3]) figures.append(fig1) ax1.set_xlim([3,5]) figures.append(fig1) pdf = PdfPages('output.pdf') for figure in figures: canvas = FigureCanvasPdf(figure) figure.savefig(pdf, format="pdf") pdf.close() In the actual code the list of figures is returned from a function to another part of the code, but this is roughly equivalent. I realise in this example i can just write directly to the pdf file after appending fig1, but in the actual code i do not wish to write the data to a file until later on. The output i get from this code is two identical pages of PDF where the x limits are set to 3,5. I understand this is because I am simply making two identical references to the figure object in the list and by modifying fig1 i also affect the fig1 that is 'stored' in the first position of the array. My question is how do I avoid this? I have tried to use copy.copy() and copy.deepcopy(). The former does not work correctly (for fairly obvious reasons) and the latter does not work with the figure object giving me an error: "NotImplementedError: TransformNode instances can not be copied. Consider using frozen() instead." So, how can i go about making a list of 'charts' and then output them selectively to a PDF at a later time? Many thanks and apologies for any information I have left out. Stephen P.S. as an aside, can anyone confirm whether it is possible to write a multipage PDF using the cairo backend? -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users