[Matplotlib-users] fading line plot
Hi everyone, I've been looking into making an animation of a mechanical system. In its first incarnation, my plan was as follows: 1) Make a fading line plot of two variables (say, x and y) 2) Run a series of such plots through ffmpeg/avencode to generate an animation First, I'm wondering whether there's a built-in way of making a fading line plot, i.e. a plot where one end of the line is plotted with high alpha, the other end with low alpha, and intermediate line segments with linearly scaled alpha. For now, I've done this by manually chunking the x and y arrays and plotting each chunk with different alpha. Is there a better way? Is there interest in creating such a plotting function and adding it to matplotlib? Second, is there a way of integrating the chunked generation of fading lines with the animation generating features of matplotlib? It seems possible, although a bit clunky, at present, but maybe someone has a better idea at what overall approach to take than I do. Cheers Paul -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] specgram bug
Hi, not 100% sure this is a bug, but here goes: In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power spectral density) and specgram returns the real part of the fourier transform. % grep -n Pxx.real mlab.py 390:return Pxx.real,freqs 470:Pxx = Pxx.real #Needed since helper implements generically (git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github today) This all means that the specgram plot routine yields the real part of the Fourier transform, rather than its absolute square (forgetting normalization for simplicity of discussion). The definition of the PSD is that it is the absolute square of the Fourier transform: https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density Hence, I believe this is a bug which should be fixed. Cheers Paul -- Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug in mpl_toolkits.axes_grid1.AxesGrid?
Hi! I am wondering if there is a bug in: mpl_toolkits.axes_grid1.AxesGrid I am trying to run this example (I am of course working on something else, but I am trying to build a minimal example of my problem): http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_grid.html This would be a very compact and nice way of showing my results, and I am beginning to love it. There is one thing, though. Given the code attached at the end of this message, the two versions produce figures that look identical. To my mind, however, it doesn't exactly seem that the colorbars are shared in any real sense. Try commenting out the 2-3 lines marked # Version 1 and # Version 2. I attach two plots of what I get: same-looking plots with wildly varying colorbar numbers. I'd like to get the numbers to be the same. TL;DR: In version 1 I am scaling the data for one of the contour plots by a factor 1000, and would expect that plot to look quite different from the others. Cheers Paul. # CODE: import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import AxesGrid def get_demo_image(): import numpy as np from matplotlib.cbook import get_sample_data f = get_sample_data(axes_grid/bivariate_normal.npy, asfileobj=False) z = np.load(f) # z is a numpy array of 15x15 return z, (-3,4,-4,3) def demo_grid_with_single_cbar(fig): A grid of 2x2 images with a single colobar grid = AxesGrid(fig, 132, # similar to subplot(132) nrows_ncols = (2, 2), axes_pad = 0.0, share_all=True, label_mode = L, cbar_location = top, cbar_mode=single) Z, extent = get_demo_image() # Version 1 #for i in range(3): #im = grid[i].imshow(Z, extent=extent, interpolation=nearest) #im = grid[3].imshow(1000 * Z, extent=extent, interpolation=nearest) # Version 2 for i in range(4): im = grid[i].imshow(Z, extent=extent, interpolation=nearest) # The rest is the same grid.cbar_axes[0].colorbar(im) # This affects all axes as share_all = True. grid.axes_llc.set_xticks([-2, 0, 2]) grid.axes_llc.set_yticks([-2, 0, 2]) if 1: F = plt.figure(1, (5.5, 2.5)) F.subplots_adjust(left=0.05, right=0.98) demo_grid_with_single_cbar(F) plt.savefig('cbars') #plt.draw() #plt.show() inline: cbars-version-1.pnginline: cbars-version-2.png-- vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] png to slideshow (gif)
On 18. mars 2011, at 12.49, Rita wrote: If I have 30 PNGs and i would like to make a slideshow or an animated gif what is the best way to do this? Can matplotlib do this? I have used ffmpeg in the past with some success. It generates mpeg 4 video files, but maybe that's OK for you? The only requirement is that your files are named on the format file_.png file_0001.png ... See examples below. Cheers Paul. + ffmpeg -qscale 5 -r 20 -b 9600 -i img%04d.png movie.mp4 ffmpeg -qscale 5 -r 20 -i img%04d.png movie.mp4 # The options are # # * -qscale 5 … define fixed video quantizer scale (VBR) where 1 is the best and 31 the worst. Since mpeg/jpeg has problems to compress line graphics it’s a good idea to set this variable close to 1. You get a big movie file, but otherwise the movie doesn’t look, well, that good. # * -r … framerate # * -b … video bitrate # * -i input files, %04d says that we have four numbers in the filename where the number is filled with zeros left of it. # * movie.mp4 is the filename, the extension says that it is a quicktime movie. You can also create a Macromedia Flash movie by using the .flv extension. # Info from: http://tinyurl.com/dlwlnk # Note that the images have to be numbered 1,2,3,... not (for example) 2, 4, 6... or 10, 20, 30... -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] pyplot.figure() memory leak?
Hi! This simple loop: import time import pylab for i in range(100): ... time.sleep(0.1) ... pylab.figure() ... will have python use more and more memory. While this is not technically a memory leak, it becomes one in practice, if I want to create a large number of figure objects. How can I free the memory used by one or all figure objects? Cheers Paul -- What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend outside plot?
Matplotlib is great! I created all my figures in this paper [0] using matplotlib. I am impressed with the quality you get. I attach the plotting script for fig. 9, which does exactly what you want, I believe. There is a lot of other junk in there, so look for the legend function, it all happens in one line. Cheers, Paul. [0] http://arxiv.org/abs/1011.3399, the paper should appear in phys. rev. B soon. #! /usr/bin/env python Generate a plot of dipole moments as function of frequency for different substrates. import sys import numpy import matplotlib matplotlib.use('pdf') from matplotlib import pyplot def setparams(): 'Adjust the rcparams before plotting.' matplotlib.rcParams['figure.figsize'] = [3.0, 5.0] #matplotlib.rcParams['legend.borderpad'] = 0.0 matplotlib.rcParams['figure.subplot.left'] = 0.12 matplotlib.rcParams['figure.subplot.right'] = 0.96 matplotlib.rcParams['figure.subplot.bottom'] = 0.08 matplotlib.rcParams['figure.subplot.top'] = 0.94 matplotlib.rcParams['legend.fontsize'] = 10.0 matplotlib.rcParams['font.size'] = 10.0 def readfiles(): #eps_1 = numpy.loadtxt('Drude-dimer-on-vacuum.dat') #eps_2 = numpy.loadtxt('Drude-dimer-on-2.25.dat') #eps_3 = numpy.loadtxt('Drude-dimer-on-3.0.dat') #eps_5 = numpy.loadtxt('Drude-dimer-on-5.0.dat') #eps_10 = numpy.loadtxt('Drude-dimer-on-10.0.dat') #eps_20 = numpy.loadtxt('Drude-dimer-on-20.0.dat') filenames = ['dipole_1_pos-_eps_01.dat', 'dipole_1_pos-_eps_02.dat', 'dipole_1_pos-_eps_10.dat'] eps_1, eps_2, eps_10 = map(numpy.loadtxt, filenames) freqs = eps_1[:, 0] #return [freqs, eps_1[:, 1:], eps_2[:, 1:], eps_3[:, 1:], eps_5[:, 1:], #eps_10[:, 1:], eps_20[:, 1:]] return [freqs, eps_1[:, 1:], eps_2[:, 1:], eps_10[:, 1:]] def main(): setparams() tmp = readfiles() freqs = tmp[0] ps = tmp[1:] #fig = pyplot.figure() pyplot.subplots_adjust(hspace=0.0001) axes = [] for i, p in enumerate(ps): ax = pyplot.subplot(310 + (1 + i)) for j in range(3): labeltext = r'$\bm{E}_{0}\parallel\bm{\hat{%s}}$' style = ['b-', 'g--', 'r:'][j] plot = ax.plot(freqs, p[:, j], style, label=labeltext % 'xyz'[j]) ax.set_xlim(freqs[0], freqs[-1]) ax.set_ylim(0, 10) ax.set_yticks(numpy.arange(1, 9 + 1, 2)) ax.text(1.55, 8.0, r'$\mathrm{%s} \,\,\, \varepsilon_- = %.1f$' % (['(a)', '(b)', '(c)'][i], [1.0, 2.0, 10.0][i])) if i == 1: pyplot.ylabel(r'$\bar{p}(\omega)$') axes.append(ax) legend = axes[0].legend(loc=(-0.17, 1.03), ncol=3) legend.draw_frame(False) for ax in axes[:-1]: pyplot.setp(ax.get_xticklabels(), visible=False) pyplot.xlabel('$\hbar \omega \,\mathrm{[eV]}$') pyplot.savefig('Ag-dimer-dipole') if __name__ == '__main__': main() On 11. feb. 2011, at 00.20, Jeff Layton wrote: Good evening, I've been trying to find a way to move the legend outside the plot so it doesn't cover it up. I've seen some things online but I can quite get them to work (probably just my lack of knowledge about matplotlib). The section of code creating the plot looks like, fig = plt.figure() ax = fig.add_subplot(1,1,1); p1 = ax.bar(ind, IO_Time_Plot, width, color=r, align='center'); p2 = ax.bar(ind, Diff_Plot, width, color=y, bottom=IO_Time_Plot, align='center'); ax.set_ylabel('Time (secs)'); ax.set_title('Elapsed Time and IO Time',fontstyle='italic'); ax.set_xticks(ind); group_labels = []; for item in names: group_labels.append(item); ax.set_xticklabels(group_labels); fig.autofmt_xdate(); #ax.legend( bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.); ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time')); You can see my attempt at moving the legend outside the bounding box but when I try this, the legend never appears. TIA! Jeff -- The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel
Re: [Matplotlib-users] plots do not scale to size
On 10. juni 2009, at 14.53, John Hunter wrote: On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton Letnespaul.anton.let...@gmail.com wrote: This _must_ be a bug. Consider the following: ## import matplotlib No it is not a bug -- mpl is doing what you tell it to do. Consider figure() subplot(111) plot([1,2,3]) xlabel('hi mom', fontsize=100) Each command has precise meaning -- the fig creates a figure using the default size, the subplot occupies a fraction of that figure according to the default ratios in the subplots_adjust parameters, and the xlabel makes a label at an indicated physical size. You may not be explicitly setting those sizes, but they are all defined via defaults in the matplotlibrc. We try and make mpl do what you tell it to do, not to try and out-smart you and do what we think you are telling it to do. Now I definitely support the idea that we should have a *feature* to auto-adjust the subplots_adjust params and fontsizes so that it just works more often. But this should be an optional feature so the user who wants to express their intent clearly will not constantly be stymied by mpl adjusting the sizes. Michael Droettboom has worked on it and it is a difficult problem to get right. JDH I don't mean to bother people with this question again, but has anyone implemented this auto-adjust feature that John was talking about? It would be nice not having to adjust matplotlib.rcParams['figure.subplot.left'] (and friends) in every plot script, or alternatively, through a clever hierarchy of matplotlibrc files. By the way: kudos to matplotlib in every other respect! Cheers Paul -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] TeX fails in general
On 18. aug. 2010, at 23.21, Friedrich Romstedt wrote: 2010/8/17 Paul Anton Letnes paul.anton.let...@gmail.com: If I try to use LaTeX for text processing (i.e. text.usetex : True in my matplotlibrc), I get a cryptic LaTeX error which didn't use to be there before. I get the same problem when using matplotlib-0.98.5 which I compiled from source, and matplotlib-1.0.0 from macports. My python version is 2.6.5 (from macports) and I am running Mac OS X 10.6.4. The error messages are pretty much the same no matter what I plot, and everything works fine if text.usetex : False. Can't reproduce the error here on Mac OS X 10.6.4 64bit with framework-compiled Python 2.6.5 and matplotlib from svn. I could imaging you are missing file creation rights or similar in the directory where matplotlib wants to place that foobar123345.tex file. Friedrich It seems that I had changed an environment variable (TEXINPUTS) elsewhere, meaning that latex didn't pick up the right source file. Everything seems fine now! Paul -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] TeX fails in general
Hello everyone. If I try to use LaTeX for text processing (i.e. text.usetex : True in my matplotlibrc), I get a cryptic LaTeX error which didn't use to be there before. I get the same problem when using matplotlib-0.98.5 which I compiled from source, and matplotlib-1.0.0 from macports. My python version is 2.6.5 (from macports) and I am running Mac OS X 10.6.4. The error messages are pretty much the same no matter what I plot, and everything works fine if text.usetex : False. Regards Paul. # This script demonstrates that font effects specified in your pdftex.map # are now supported in pdf usetex. import matplotlib matplotlib.rc('text', usetex=True) import pylab def setfont(font): return r'\font\a %s at 14pt\a ' % font for y, font, text in zip(range(5), ['ptmr8r', 'ptmri8r', 'ptmro8r', 'ptmr8rn', 'ptmrr8re'], ['Nimbus Roman No9 L ' + x for x in ['', 'Italics (real italics for comparison)', '(slanted)', '(condensed)', '(extended)']]): pylab.text(0, y, setfont(font) + text) pylab.ylim(-1, 5) pylab.xlim(-0.2, 0.6) pylab.setp(pylab.gca(), frame_on=False, xticks=(), yticks=()) pylab.title('Usetex font effects') pylab.savefig('usetex_fonteffects.pdf') ~/Desktop $ python usetex_fonteffects.py Traceback (most recent call last): File usetex_fonteffects.py, line 22, in module pylab.savefig('usetex_fonteffects.pdf') File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py, line 363, in savefig return fig.savefig(*args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py, line 1084, in savefig self.canvas.print_figure(*args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py, line 1886, in print_figure **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py, line 1696, in print_pdf return pdf.print_pdf(*args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_pdf.py, line 2156, in print_pdf self.figure.draw(renderer) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py, line 798, in draw func(*args) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py, line 1934, in draw a.draw(renderer) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/text.py, line 524, in draw bbox, info = self._get_layout(renderer) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/text.py, line 298, in _get_layout ismath=False) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_pdf.py, line 1766, in get_text_width_height_descent renderer=self) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/texmanager.py, line 606, in get_text_width_height_descent dvifile = self.make_dvi(tex, fontsize) File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/texmanager.py, line 371, in make_dvi string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + report) RuntimeError: LaTeX was not able to process the following string: 'lp' Here is the full report generated by LaTeX: This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live/MacPorts 2009_6) entering extended mode ! I can't find file `50c9e93d8d242d27078b4854fe3aa6e5.tex'. * 50c9e93d8d242d27078b4854fe3aa6e5.tex (Press Enter to retry, or Control-D to exit) Please type another input file name ! Emergency stop. * 50c9e93d8d242d27078b4854fe3aa6e5.tex No pages of output. Transcript written on texput.log. -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer
Re: [Matplotlib-users] problems with contourf plots
Hi, thanks a lot Eric! I'm sorry I bothered you with this. There's obviously an error in how my data generating script works. cheers, Paul. On 27. juli. 2009, at 21.48, Eric Firing wrote: Paul Anton Letnes wrote: Hi, I'm having strange problems with contourf plots. The plotting routine is rather elaborate, so I don't have an easy way to reproduce the problem (unfortunately). The problem should be evident from the attachments. As you can see, the contourf routine doesn't color the whole plot area. Also, after some editing in Adobe Illustrator, it is also easy to see that some contours are drawn on top of others. This must surely be a bug? It is in your data file and/or your handling of it, not in contourf. The problem is that your theta variable is not monotonic--it starts and ends with zero. If you chop off the last line of your data file, or equivalently chop off the last column of each array after you read it, like this: return thetas[:,:-1], freqs[:,:-1], Es[:,:-1] then the contouring works fine. Eric I would like to note that this happened on the TkAgg (using show()), Agg (png format), ps (eps format), macosx (using show()) and pdf backends. Also, for some data sets, the plot turns out just fine - I get this problem only for some data sets. I have no idea how to debug this, so I'd appreciate any hints you might provide. The file original.pdf shows the matplotlib result. The file edited.pdf shows that you have contours on top of each other. The file gnuplot.png gives an idea of what the end result should be: a lot of bumps around 3.5 eV, but some of this structure is missing from the contourf plots. The gnuplot plot was generated from the same data (ASCII text) file. Best regards, Paul. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Quiver plot of a netcdf file
In addition to scipy.io, there are some pure python netcdf readers, including pupynere (might be easier to install a pure python module?). Also, you have ScientificPython.io.netCDF, in case this is more convenient for you. ncdump is almost certainly not the way to go, it is best suited for human inspection of the file contents. If you absolutely want to use it, consider using the C source creator in ncdump to import it (Cython or similar?). Good luck, Paul. On Thu, Jun 11, 2009 at 8:09 PM, JPKay kay1...@vandals.uidaho.edu wrote: Hello, I am trying to use matplotlib to create a quiver plot of a NetCDF file with the extension .nc. The Netcdf file is a series of arrays that contain information about the stress tensors on a globe. I am struggling to import the file into python and having the quiver data show up. To import the file I have been using: “ncdump file.nc” Any thoughts would be appreciated. Thanks, Jon -- View this message in context: http://www.nabble.com/Quiver-plot-of-a-netcdf-file-tp23986313p23986313.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plots do not scale to size
On 9. juni. 2009, at 17.18, Jouni K. Seppänen wrote: Chaitanya Krishna icym...@gmail.com writes: On Tue, Jun 9, 2009 at 12:05 PM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: When I run the script below, the xlabel and ylabel do not show up. If I increase the figure size, it all works fine. I am not sure if it is a bug. But, it is usual that such a thing happens when you are making small figures (like in your case). Arguably it is a bug, since it is reasonable to expect that when you set an xlabel or ylabel (or, say, large yticklabels), it shows up in the figure. There are at least two problems to solve here: what should the user interface be like, and how can it best be implemented? The user interface question seems difficult to me. If you set the figure size to something small (as in this case) and then add labels, should matplotlib reduce the area available for the plot? Or should it reduce the font size of the labels and the tick labels, and perhaps the amount of white space between the axes and the labels? Or some combination of these? The implementation question could also be somewhat hairy, since the bounding box of text objects depends on the backend. If agg and pdf disagree on the size of a label, is it OK to get different-looking results in png and pdf? -- Jouni K. Seppänen http://www.iki.fi/jks -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users This _must_ be a bug. Consider the following: ## import matplotlib matplotlib.rcParams['figure.figsize'] = [8.85, 3.20] matplotlib.use('pdf') from pylab import * xs = linspace(0, 2 * pi) ys = sin(xs) plot(xs, ys) xlabel(r'$T_{est}$') ylabel('y axis') savefig('test') ## Here, the vertical size is clearly large enough for a label, as it is a full inch larger than in the previous example. However, the xlabel is truncated. This _must_ be a bug. When I make a plot, I would expect that all parts of the plot appear on the plot. As an example, in Gnuplot, the text just appears in the right place, but is too large (overlaps the plot, etc). Hence, you see for yourself that the font size is the problem. Anyway, it can't be the font size here, as the xlabel was completely outside the bounding box (I'm not sure of the terminology). To me, it just looks like a problem with the scaling - the plot looks perfectly OK in Illustrator, disregarding that it doesn't fit inside the viewing window. I'm not an expert, and I certainly don't know how to fix this. But I do know that other software manages this nicely. Don't get me wrong, I use matplotlib because I like it - but it should be possible to fix this problem. Best regards, Paul. -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plots do not scale to size
On 10. juni. 2009, at 14.53, John Hunter wrote: On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton Letnespaul.anton.let...@gmail.com wrote: This _must_ be a bug. Consider the following: ## import matplotlib No it is not a bug -- mpl is doing what you tell it to do. Consider figure() subplot(111) plot([1,2,3]) xlabel('hi mom', fontsize=100) Each command has precise meaning -- the fig creates a figure using the default size, the subplot occupies a fraction of that figure according to the default ratios in the subplots_adjust parameters, and the xlabel makes a label at an indicated physical size. You may not be explicitly setting those sizes, but they are all defined via defaults in the matplotlibrc. We try and make mpl do what you tell it to do, not to try and out-smart you and do what we think you are telling it to do. Now I definitely support the idea that we should have a *feature* to auto-adjust the subplots_adjust params and fontsizes so that it just works more often. But this should be an optional feature so the user who wants to express their intent clearly will not constantly be stymied by mpl adjusting the sizes. Michael Droettboom has worked on it and it is a difficult problem to get right. JDH Hm, I see. Thanks for an informative answer. I'll dig into my rcParams and matplotlibrc then... Best regards, Paul. -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plots do not scale to size
Dear all. When I run the script below, the xlabel and ylabel do not show up. If I increase the figure size, it all works fine. If I open the file in Adobe Illustrator, the x and ylabels are both there, but outside the canvas (or bounding box or whatever it is called). I believe this must be a bug? I moved my matplotlibrc file out of its usual location to make sure I don't have any funny settings which screws things up. I also deleted the tex cache to avoid any tex-related problems. Best regards, Paul. ## import matplotlib matplotlib.rcParams['figure.figsize'] = [2.85, 2.20] matplotlib.use('pdf') from pylab import * xs = linspace(0, 2 * pi) ys = sin(xs) plot(xs, ys) xlabel(r'$T_{est}$') ylabel('y axis') savefig('test') show() test.pdf Description: Adobe PDF document -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plots do not scale to size
Dear all. When I run the script below, the xlabel and ylabel do not show up. If I increase the figure size, it all works fine. If I open the file in Adobe Illustrator, the x and ylabels are both there, but outside the canvas (or bounding box or whatever it is called). I believe this must be a bug? I moved my matplotlibrc file out of its usual location to make sure I don't have any funny settings which screws things up. I also deleted the tex cache to avoid any tex-related problems. Best regards, Paul. import matplotlib matplotlib.rcParams['figure.figsize'] = [2.85, 2.20] matplotlib.use('pdf') from pylab import * xs = linspace(0, 2 * pi) ys = sin(xs) plot(xs, ys) xlabel(r'$T_{est}$') ylabel('y axis') savefig('test') show() test.pdf Description: Adobe PDF document -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: making publication quality plots
Hi Chaitanya (and everyone else), thanks for some nice advice! The font and legend frame tips worked quite well. I would appreciate it if it was possible to remove the legend frame by default, i.e. in the matplotlibrc file, if possible. In my opinion, this frame clutters the plot unnecessarily; I rarely see such frames in publications. Thanks! Paul. Begin forwarded message: From: Chaitanya Krishna icym...@gmail.com Date: 3. juni 2009 08.26.07 GMT+02:00 To: Paul Anton Letnes paul.anton.let...@gmail.com Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] making publication quality plots Hi Paul, Can you try font.size: 10 legend.fontsize: small [or medium] in your rc file. Defining the fontsize and then defining the fontsize of the xtick labels, legend etc with respect to this font size seems to work better than defining everything by hand. Switching off the legend frame does seem to save some place. You can use pylab.legend('your legend').draw_frame(False) Cheers, Chaitanya On Wed, Jun 3, 2009 at 8:11 AM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: On 30. mai. 2009, at 13.56, John Hunter wrote: On Sat, May 30, 2009 at 3:50 AM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: Hello again, I can set the figure size and font size, that all works fine. However, the legend is prohibitively large: for a plot 3 inches wide (why doesn't matplotlib use centimeters or similar?), the legend takes up about one third of the plot. This does not look too good... Please post a complete example. As for inches vs cm, that is my fault -- I can't remember if it was for matlab compatibility, or due to my provincial ways this side of the pond. JDH Hi, This is my function which does the plotting. The coeffarr is a 2D array (function uses 7 first columns) with first column being frequencies, other columns being real/imag part of whatever I'm plotting. # import matplotlib matplotlib.use('ps') import pylab def plot(coeffarr): 'Do the actual plotting.' nfreqs, ncoeffs = coeffarr.shape legends = [] for i in range(1, 6, 2): # real part columns pylab.plot(coeffarr[:,0], coeffarr[:,i], RE_STYLE) legends.append('l = %i' % int((i + 1) / 2)) pylab.plot(coeffarr[:,0], coeffarr[:,i+1], IM_STYLE) legends.append('l = %i' % int((i + 1) / 2)) pylab.legend(legends) pylab.xlabel('Frequency [eV]') pylab.ylabel('$A_{lm}R^{-l-1}$') pylab.savefig(PLOTFILE) My matplotlibrc file is essentially this: backend : MacOSX # added by paulanto on 16. feb. 08 numerix : numpy # numpy, Numeric or numarray lines.linewidth : 1.0 # line width in points font.family : serif font.size : 10.0 text.usetex : True axes.linewidth : 1.0 # edge linewidth legend.fontsize : 10.0 figure.figsize : 3.0, 2.3# figure size in inches Is this complete enough? If you do the plot, you'll see that the plot is about one column wide (7 cm-ish) and that the legend is relatively large. I made similar size plots in Gnuplot before, at font size 10, but the legend was somehow less dominant. Also, will it help getting rid of the rectangle? cheers, Paul. -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making publication quality plots
On 30. mai. 2009, at 13.56, John Hunter wrote: On Sat, May 30, 2009 at 3:50 AM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: Hello again, I can set the figure size and font size, that all works fine. However, the legend is prohibitively large: for a plot 3 inches wide (why doesn't matplotlib use centimeters or similar?), the legend takes up about one third of the plot. This does not look too good... Please post a complete example. As for inches vs cm, that is my fault -- I can't remember if it was for matlab compatibility, or due to my provincial ways this side of the pond. JDH Hi, This is my function which does the plotting. The coeffarr is a 2D array (function uses 7 first columns) with first column being frequencies, other columns being real/imag part of whatever I'm plotting. # import matplotlib matplotlib.use('ps') import pylab def plot(coeffarr): 'Do the actual plotting.' nfreqs, ncoeffs = coeffarr.shape legends = [] for i in range(1, 6, 2): # real part columns pylab.plot(coeffarr[:,0], coeffarr[:,i], RE_STYLE) legends.append('l = %i' % int((i + 1) / 2)) pylab.plot(coeffarr[:,0], coeffarr[:,i+1], IM_STYLE) legends.append('l = %i' % int((i + 1) / 2)) pylab.legend(legends) pylab.xlabel('Frequency [eV]') pylab.ylabel('$A_{lm}R^{-l-1}$') pylab.savefig(PLOTFILE) My matplotlibrc file is essentially this: backend : MacOSX # added by paulanto on 16. feb. 08 numerix : numpy # numpy, Numeric or numarray lines.linewidth : 1.0 # line width in points font.family : serif font.size : 10.0 text.usetex : True axes.linewidth : 1.0 # edge linewidth legend.fontsize : 10.0 figure.figsize : 3.0, 2.3# figure size in inches Is this complete enough? If you do the plot, you'll see that the plot is about one column wide (7 cm-ish) and that the legend is relatively large. I made similar size plots in Gnuplot before, at font size 10, but the legend was somehow less dominant. Also, will it help getting rid of the rectangle? cheers, Paul. -- OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making publication quality plots
Hello again, I can set the figure size and font size, that all works fine. However, the legend is prohibitively large: for a plot 3 inches wide (why doesn't matplotlib use centimeters or similar?), the legend takes up about one third of the plot. This does not look too good... cheers, Paul On 29. mai. 2009, at 17.38, Damon McDougall wrote: Hi Paul, You could set the figure size and font size in inches of your plot in matplotlib to be the same as that of the physical size it will appear on paper. That way, all your axes labels and plot text will be the same size as the text in your latex document. Is this what you want? Regards, --Damon On 29 May 2009, at 16:25, Paul Anton Letnes wrote: Howdy y'all! I'm trying to make a publication quality plot for a two-column latex article. I'm using latex for text processing, so the plot quality itself is impeccable. However, as I scale the plot size down, the legend becomes extremely large compared to the plot itself. Has anyone solved this problem in a good manner? I'm not willing to make do without the legend. cheers, Paul. -- Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, Big Spaceship. http://p.sf.net/sfu/creativitycat-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, Big Spaceship. http://p.sf.net/sfu/creativitycat-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] making publication quality plots
Howdy y'all! I'm trying to make a publication quality plot for a two-column latex article. I'm using latex for text processing, so the plot quality itself is impeccable. However, as I scale the plot size down, the legend becomes extremely large compared to the plot itself. Has anyone solved this problem in a good manner? I'm not willing to make do without the legend. cheers, Paul. -- Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, Big Spaceship. http://p.sf.net/sfu/creativitycat-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot windows
On 24. feb.. 2009, at 08.11, Eric Firing wrote: Paul Anton Letnes wrote: Hello, I want to save a large number of figures to file, roughly like this: import pylab for i in xrange(100): pylab.plot(x[i], y[i]) pylab.savefig('plot' + str(i) + '.eps') pylab.figure() However, a large number of figure windows show up on screen, and eventually, the application runs out of memory and crashes. How do I avoid these windows? Replace the pylab.figure() command with pylab.clf(), or with pylab.close(). Eric Regards, Paul. Thanks, this helps a lot. Is it possible to completely eliminate the windows popping up? Though not very important, it is still annoying that windows pop up when running a script in the background. Paul. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Error messages with xpdf / LaTeX
Hi everyone, I'm having issues using LaTeX text processing with the xpdf distiller. After playing with my settings, I finally managed to get vector graphics output using LaTeX test processing. However, a weird error message pops up in the terminal every time (mostly annoying, the plotting actually works): Error: No paper information available - using defaults Error: No display font for 'Courier' Error: No display font for 'Courier-Bold' Error: No display font for 'Courier-BoldOblique' Error: No display font for 'Courier-Oblique' Error: No display font for 'Helvetica' Error: No display font for 'Helvetica-Bold' Error: No display font for 'Helvetica-BoldOblique' Error: No display font for 'Helvetica-Oblique' Error: No display font for 'Symbol' Error: No display font for 'Times-Bold' Error: No display font for 'Times-BoldItalic' Error: No display font for 'Times-Italic' Error: No display font for 'Times-Roman' Error: No display font for 'ZapfDingbats' I attach my matplotlibrc file for reference. Note especially the stuff at the end with usetex=True and distiller = xpdf. If you know any other settings that might work better, please let me know! I suspect these settings are the sources of my annoying error messages. Cheers, Paul. matplotlibrc Description: Binary data -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error messages with xpdf / LaTeX
On 23. feb.. 2009, at 14.51, Darren Dale wrote: On Mon, Feb 23, 2009 at 3:59 AM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: Hi everyone, I'm having issues using LaTeX text processing with the xpdf distiller. After playing with my settings, I finally managed to get vector graphics output using LaTeX test processing. However, a weird error message pops up in the terminal every time (mostly annoying, the plotting actually works): Error: No paper information available - using defaults Error: No display font for 'Courier' Error: No display font for 'Courier-Bold' Error: No display font for 'Courier-BoldOblique' Error: No display font for 'Courier-Oblique' Error: No display font for 'Helvetica' Error: No display font for 'Helvetica-Bold' Error: No display font for 'Helvetica-BoldOblique' Error: No display font for 'Helvetica-Oblique' Error: No display font for 'Symbol' Error: No display font for 'Times-Bold' Error: No display font for 'Times-BoldItalic' Error: No display font for 'Times-Italic' Error: No display font for 'Times-Roman' Error: No display font for 'ZapfDingbats' I attach my matplotlibrc file for reference. Note especially the stuff at the end with usetex=True and distiller = xpdf. If you know any other settings that might work better, please let me know! I suspect these settings are the sources of my annoying error messages. Do you have the relevant latex font packages installed? Like psnfss? I suspect this is an issue with your latex installation, not matplotlib. Darren First of all, the No paper info available should not be relevant for fonts? Second, this problem appeared recently, after an upgrade of matplotlib. But, it could be that you are right. I still don't know how to fix it, though, and latex itself gives no error messages. I'm thinking there's something with xpdf. Paul.-- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plot windows
Hello, I want to save a large number of figures to file, roughly like this: import pylab for i in xrange(100): pylab.plot(x[i], y[i]) pylab.savefig('plot' + str(i) + '.eps') pylab.figure() However, a large number of figure windows show up on screen, and eventually, the application runs out of memory and crashes. How do I avoid these windows? Regards, Paul. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users