[Matplotlib-users] Rendering SciPy docstrings as markup text within matplotlib
Hi, SciPy (and NumPy) docstrings are written with a special kind of mark up: For example, the docstring for the russellrao distance function looks like this: '\nComputes the Russell-Rao dissimilarity between two boolean 1-D arrays.\n\nThe Russell-Rao dissimilarity between two boolean 1-D arrays, `u` and\n`v`, is defined as\n\n.. math::\n\n \\frac{n - c_{TT}}\n {n}\n\nwhere :math:`c_{ij}` is the number of occurrences of\n:math:`\\mathtt{u[k]} = i` and :math:`\\mathtt{v[k]} = j` for\n:math:`k < n`.\n\nParameters\n--\nu : (N,) array_like, bool\nInput array.\nv : (N,) array_like, bool\n Input array.\n\nReturns\n---\nrussellrao : double\n The Russell-Rao dissimilarity between vectors `u` and `v`.\n\n' What's the most efficient way to turn this into a format where you can format it nicely as a matplotlib text object? I tried: fig = plt.figure() ax = fig.add_subplot(111) props = dict(boxstyle='round', facecolor='wheat', alpha=0.5) textstr = dist_fcn.__doc__ textstr = textstr.replace('math:',' ') textstr = textstr.replace('`', '$') textstr = textstr.replace('\n\n where', '$\n\n where') ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14, verticalalignment='top', bbox=props) Which does an 'ok' job, at best, since fractions aren't converted properly. Is there a way to do it nicely short of using some horrendous regular expressions? Federico -- Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Changing a single marker on a line
Hi, I have a very simple request - I am drawing a line with n points, using a particle marker - something like: x = np.linspace(1,10,11) ** 2 y = np.linspace(1,10,11) plot(x,y,'ro') Is there any way to change the 7th dot (7, 49) to be a blue star instead of a red circle? I was considering using the scatter function to scatter points 1:6 and 8:10 separately with 'ro' and then scatter 7 with the right properties... is that the easiest way? Thanks a lot, Federico -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bar graphs showing up incorrectly until they are resized:
I think you are correct - and I think the fact that the line width of the error bar is larger (compared to the size of the rectangle) gives the impression the top rectangle is actually darker. I see - it's just a matter of playing around with the error bar properties to make it look pretty. Thanks, Federico On Thu, Feb 23, 2012 at 5:13 PM, Benjamin Root wrote: > > > On Thu, Feb 23, 2012 at 10:03 AM, federico vaggi > wrote: > >> Hi Ben, >> >> In the pre-resizing pictures, each bar is drawn as two rectangles, the >> first until the lower margin of the standard deviation, the second until >> the mean. >> >> It looks like it draws one rectangle from: >> >> 0:(MEAN-STD) >> >> and another from: >> >> MEAN-STD to MEAN+STD >> >> After resizing, it is just a single rectangle with the standard deviation >> drawn as normal. >> >> I presume the 2nd version is meant to be correct, but absolutely no >> graphics properties are altered (besides manually re-sizing the window). >> >> Federico >> >> > Sorry, I am not seeing what you are saying. Just to be clear, when you > say "bar", are you referring to the gray rectangles that denote the mean or > the errorbars that denote the standard deviations? > > What might be confusing is that in the first graph, the "cap" of the > errorbars (the horizontal line on the ends of each errorbar) is almost the > same width as the gray bars themselves. This sort of makes it look like > there are two gray bars stacked on top of each other. Is this what you are > referring to? > > Ben Root > > -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bar graphs showing up incorrectly until they are resized:
Hi Ben, In the pre-resizing pictures, each bar is drawn as two rectangles, the first until the lower margin of the standard deviation, the second until the mean. It looks like it draws one rectangle from: 0:(MEAN-STD) and another from: MEAN-STD to MEAN+STD After resizing, it is just a single rectangle with the standard deviation drawn as normal. I presume the 2nd version is meant to be correct, but absolutely no graphics properties are altered (besides manually re-sizing the window). Federico On Thu, Feb 23, 2012 at 4:54 PM, Benjamin Root wrote: > > > On Thu, Feb 23, 2012 at 5:02 AM, federico vaggi > wrote: > >> Hi, >> >> I am using matplotlib to draw a few bar plots. The library works >> wonderfully, but the figures are drawn incorrectly until they are resized >> >> Here is the figure before resizing: >> >> http://imgur.com/MKATg >> >> here is after resizing: >> >> http://imgur.com/bSiOT >> >> It seems that the rectangles of the bar somehow are not drawn properly. >> >> Any suggestions on how to fix it automatically? >> >> Federico >> >> > Federico, > > Could you please be a bit more specific about what you think is wrong. I > see a number of possibilities, but I can't be sure what you are referring > to. > > Ben Root > > -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bar graphs showing up incorrectly until they are resized:
Hi, I am using matplotlib to draw a few bar plots. The library works wonderfully, but the figures are drawn incorrectly until they are resized Here is the figure before resizing: http://imgur.com/MKATg here is after resizing: http://imgur.com/bSiOT It seems that the rectangles of the bar somehow are not drawn properly. Any suggestions on how to fix it automatically? Federico -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users