Re: [Matplotlib-users] DateFormatter + Latex issue
15/02/10 @ 19:22 (-0500), thus spake Filipe Pires Alvarenga Fernandes: Hello list, If I use DateFormatter with latex and lines breaks like this DateFormatter(\n \n %b) I get an latex error: http://pastebin.com/m5b186ded Although, if I do not use the line breaks, DateFormatter(%b) The problem disappears. Below is a script that reproduces what I'm talking about: #Example: from pylabimport * from matplotlib import rcParams rcParams['text.usetex'] = True fig = figure() ax = fig.add_subplot(111) fig.subplots_adjust(bottom=0.2) t = arange(100,110,.1) u = sin(t) v = cos(t) quiver([t],[[0]*len(t)],u,v) major = DayLocator([10,04]) minor = DayLocator() majorF = DateFormatter(\n \n %b) # problem ^^ ^^ A common mistake. You forgot to escape the \ characters. Bye. Ernest -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] DateFormatter + Latex issue
16/02/10 @ 09:03 (-0500), thus spake Filipe Pires Alvarenga Fernandes: Thanks Ernest, I had no idea that the DateFormatter was going to be treated as latex as well. Yes, all strings are processed by LaTeX. However, escaping the \ with another \ did not worked. I tried: majorF = DateFormatter(\\n \\n %b) How should I escape the \n ? In theory, \\n \\n %b or r\n \n %b, however only the former seems to work in my computer. There's another problem: \n is not a valid LaTeX command. I tried with \\ and with \newline but neither appear to work. \vspace{10pts} does insert whitespace, however I am not sure if it's the proper way of doing it... Bye. majorF = DateFormatter(\n \n %b) # problem ^^ ^^ A common mistake. You forgot to escape the \ characters. Bye. Ernest -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] DateFormatter + Latex issue
16/02/10 @ 16:20 (-0500), thus spake Filipe Pires Alvarenga Fernandes: \\ works for titles and label, but not for DateFormatter, but \vspace did the trick! Thanks again for the help. ps: I'm new to python, but maybe there is a way to mix Latex and unicode? Yes, the inputenc package from latex lets you use unicode. Try adding this to your script: plt.rc('text.latex', preamble='\usepackage[utf]{inputenc}') Note that this setting is not officially supported, whatever that means :) I also like the txfonts package: \usepackage[varg]{txfonts} which changes the default font to Times, including the text in mathematical expressions. It looks great. Cheers. Ernest -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] DateFormatter + Latex issue
Hi, 16/02/10 @ 17:01 (-0500), thus spake Jae-Joon Lee: On Tue, Feb 16, 2010 at 4:05 PM, Ernest Adrogué eadro...@gmx.net wrote: \vspace{10pts} does insert whitespace, however I am not sure if it's the proper way of doing it... Can you (or someone else) confirm this? I don't think pts is a proper tex unit and it should be \vspace{10pt}. Maybe this is a typo in the email. I'm asking this because it does not work for me, and I don't think it is supposed to work (but I may be wrong). You're right! \vspace{10pts} adds space (seems about 10 points) but it also prints a s before the space, which I didn't see before. Now, \vspace{10pt} doesn't work for me... it simply does nothing. Bye. Regards, -JJ -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] x,y ticklabel too close
Hi, 11/02/10 @ 12:40 (-0500), thus spake Filipe Pires Alvarenga Fernandes: Hello list, For the following plotI using a large font for the tick-label that causes the first x,y tick-labels to overlap http://yfrog.com/5zimageykp for now I'm padding spaces to fix the plot, like this: newtick = [-10 , -5, 0 , 5 , 10 ] pos =[-10, -5, 0, 5, 10] yticks(pos, newtick) However I was wondering if there is any automatic way to avoid or fix this overlap. Not that I'm aware of, other than changing the font size, or the axis limits. Thanks, Filipe -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] how to make an axis labels visible in axes_grid?
Hi, I have an AxesGrid instance of 2x2 subplots. I actually only want 3 subplots, so I instantiate AxesGrid with the add_all=False option, and manually add only the first 3 axes to the figure: import matplotlib as plt from mpl_toolkits import axes_grid f = plt.figure() grid = axes_grid.AxesGrid(f, 111, nrows_ncols=(2,2), add_all=False) f.add_axes(grid.axes_all[0]) f.add_axes(grid.axes_all[1]) f.add_axes(grid.axes_all[2]) Now, the problem seems to be that the top right subplot doesn't have visible labels on the x axis, and I can't figure out how to add them. Any idea of how it can be done?? Thanks. Ernest -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] how to add text below the legend
Hi, I would like to add some text relative to the legend, let's say below it, and I don't know how to get the legend coordinates so I can pass them to the text() method. Does anyone know how to do it? Alternatively, if there was a way to add text inside the legend itself, it would also do the trick. Thank you in advance. Ernest -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] font rendering quality
1/12/09 @ 09:16 (-0500), thus spake Michael Droettboom: Subpixel rendering is almost never what you want when producing a PNG file, since it is likely to be shared on a different machine requiring different subpixel settings. But it looks like your mozilla example is not using subpixel rendering either, though it appears to have very strong hinting. Yes, it's not a subpixel rendering problem. I can tell that subpixel rendering is not enabled because I'm not seeing rainbows, which I always see when it's enabled. It's definitely a hinting issue. matplotlib's Agg backends borrows a technique used by Adobe Acrobat which is to use strong hinting in the vertical direction, but more subtle hinting in the horizontal. When we did a comprehensive comparison of various hinting options about two years ago it was the strong winner. See this: http://www.mail-archive.com/matplotlib-de...@lists.sourceforge.net/msg01480.html (Unfortunately, the linked images are no longer available). If these settings are not to your liking, I would recommend the Cairo backend (which should pull in the same settings as the rest of your Gnome desktop, I believe), or one of the vector backends and then tweaking the rendering. Confirmed. The GTK backend -haven't tried Cairo yet- honours the system settings for font rendering. It looks much better now, in my opinion. Alternatively, we could provide this stretched hinting as a configuration option. If you think that's superior to these other options, please file a feature request so it doesn't get lost (and it should be a fairly straightforward patch for someone new to the code base.) Ok. I will open a feature request, if you think it's okay. I think I'll be sticking with the GTK backend for now, anyway. Thanks. Ernest -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] font rendering quality
Hi, I notice a big difference in quality between the text rendered by matplotlib and that rendered by the rest of applications. As an example, see the image attached showing the same font as shown by firefox and matplotlib respectively. Is there any config setting I can change to improve the font rendering or anything? Cheers. attachment: dejavu-sans.png-- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axis on top for barh plot
28/11/09 @ 00:17 (+0100), thus spake Mike Anderson: Hi, How can I put the bottom axis on top (or on top AND on bottom) for a barh plot? I'm trying to mimic this, made with gnuplot: http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png within matplotlib, and I've come close, http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png Also, is it possible to just have grid lines in one direction (say, vertical), I don't think the horizontal grid is necessary. It's somewhat counter-intuitive, but it can be done. You have to create some twin axes with the twiny option, then make the plot on the twin axes so it will use the top axis. The bottom axis still have to be adjusted manually to make it match the top one and remove the labels. See this example: import matplotlib.pyplot as plt import matplotlib.ticker as ticker data = [21, 17, 18, 15, 14, 11, 9, 8, 4, 6, 7, 4, 5, 1, 3, 2, 0, 0] names = ['%s%s' % (a, b) for a in 'abcdefg' for b in 'abcdefg'][:len(data)] xlim = (0, max(data)+2) fig = plt.figure() ax1 = fig.add_subplot(1,1,1) ax2 = ax1.twiny() # actual plot ax2.barh(range(len(data)), data[::-1], 1, align='center', color='red') # x-axis ax2.set_xlim(xlim) ax1.set_xlim(xlim) ax1.xaxis.set_major_formatter(ticker.NullFormatter()) # y-axis ax2.set_ylim(-0.5, len(data)-1+0.5) ax2.yaxis.set_major_locator(ticker.FixedLocator(range(len(data ax2.yaxis.set_major_formatter(ticker.FixedFormatter(names[::-1])) # grid ax2.set_axisbelow(True) ax1.set_axisbelow(True) ax1.grid(True) plt.show() If you want only a vertical grid, use ax1.xaxis.grid(True) instead of ax1.grid(True). Bye. -- 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
[Matplotlib-users] sharing the x-axis with another plot's y-axis
Hi, I know about sharing an axis with another subplot, but is it possible to share the x-axis with another subplot's y-axis (or the other way around)? Thanks. Ernest -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] unclutter the axis
hi, is there a way to put a label every two o three ticks, instead of putting it on every tick? the following works but it's a little cumbersome: ax.set_yticklabels([pos % 2 != 0 and '%.2f' % num or '' for pos, num in enumerate(ax.get_yticks())]) cheers, Ernest -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Axes.bar(orientation='horizontal') doesn't work?
Hi, I'm trying to plot some horizontal bars using the .bar() method: import matplotlib.pyplot as plt fig=plt.figure() ax=fig.add_subplot(1,1,1) ax.bar([1,2,3],[4,6,5],orientation='horizontal') raises an AssertionError: AssertionErrorTraceback (most recent call last) /home/ernest/ipython console in module() /usr/lib/pymodules/python2.5/matplotlib/axes.py in bar(self, left, height, width, bottom, color, edgecolor, linewidth, yerr, xerr, ecolor, capsize, align, orientation, log, **kwargs) 4230 # FIXME: convert the following to proper input validation 4231 # raising ValueError; don't use assert for this. - 4232 assert len(left)==nbars, incompatible sizes: argument 'left' must be length %d or scalar % nbars 4233 assert len(height)==nbars, (incompatible sizes: argument 'height' must be length %d or scalar % 4234 nbars) AssertionError: incompatible sizes: argument 'left' must be length 1 or scalar using scalars doesn't help: ax.bar(1,5,orientation='horizontal') TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' Am I doing something wrong?? -- Ernest -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Best way to plot a 2d histogram?
Hi, 1/10/09 @ 19:23 (-0500), thus spake Gökhan Sever: Although it is not an exact histogram, if you are you looking for a Pythonic alternative you might consider using Mayavi. It has ready barchart plotting functionality. Probably with some effort a 2D histogram as you linked might be created. http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#barchart Yes, it looks like it! I actually had already had a look at mayavi but found it overly complicated for a simple histogram. If it has simple bar chart functionality may be an option though. Cheers. -- Ernest -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Best way to plot a 2d histogram?
Hi, 1/10/09 @ 18:17 (-0700), thus spake Matthew Neeley: Here is a snippet that might get you started: import numpy as np from matplotlib import pyplot as plt from matplotlib import cm import mpl_toolkits.mplot3d as plt3 data = np.random.random((8,8))**4 cmap = cm.RdBu fig = plt.figure() ax = plt3.Axes3D(fig) d = 0.1 w, h = data.shape for x in range(w): for y in range(h): ax.bar3d([x+d], [y+d], [0], 1-d, 1-d, data[x,y], cmap(data[x,y])) ax.set_zlim3d((0, 1)) plt.show() Obviously, you should replace data with the actual data you want to plot (maybe numpy can help with the histogramming), and use an appropriate cmap for your data. Note that in this case the entire box is a single color, not shaded up the side as in the example you referenced; I actually like it this way but I also don't know how one would do the shading in matplotlib. I'll admit it's rather silly to have to create all these boxes individually, but that's the only way I could see to color each box according to its height. The variable d just puts gaps between boxes; you could set this to zero to make the boxes adjacent. I haven't figured out how to properly set the tick labels on the x and y axis in a 3d plot like this. Also, there are often some z-order errors with boxes occluding each other when they shouldn't. I don't know the details of how these things work internally; maybe some experts could weigh in here. Great!! I like the shading this way, so no problem here. Too bad about the rendering glitches though. Although, maybe that can be sorted out by increasing the distance between boxes...? I will experiment a little with this method of yours as it does basically what I wanted. If everything fails I think I will finally use a 2-d plot using a colour map to represent the height of bars, as in here: http://www.davidbdean.com/wp-content/uploads/hist2d.png Thanks a lot! Bye. -- Ernest -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Best way to plot a 2d histogram?
Hello all, What is the best way to plot a 2d histogram? (Note that a 2d histogram is a histogram of a bivariate variable, so it's got to be a 3d plot.) Ideally, it should look somewhat like this: http://www.desy.de/~mraue/public/rootTutorial/v0.2/histogram02.gif For now, I have tried to do surface plots, one for each bin, but this way you only get the tops of a series of imaginary columns and it looks a bit namby-pamby if you know what I mean. Any idea will be appreciated. -- Ernest -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users