### Custom colormaps

From an excellent post here , we have a clear explanation of how to make custom colormaps. Under matplotlib there is a colors module which has a method called LinearSegmentedColormap that can create a colormap for your use.

First you need to make a color dictionary which looks like this:
cdict = {'red'  :  ((0., 0., 0.), (0.5, 0.25, 0.25), (1., 1., 1.)),'green':  ((0., 1., 1.), (0.7, 0.0, 0.5), (1., 1., 1.)),'blue' :  ((0., 1., 1.), (0.5, 0.0, 0.0), (1., 1., 1.))}
For each 'primary' additive color (rgb) you have to specify a tuple (...) which inturn is a collection of triples. Each triple defines a pivot point for that color in your color map.

The triple (0.7, 0.0, 0.5) for instance, means for 'green' when the normalized value is just below 0.7 the green component should be 0.0, and just above 0.7 the green component should be 0.5. This of course creates a discontinuity in the map at 0.7. To make a continuous map all the pivot points should have the same value above and below. So the triple (0.5, 0.25, 0.25) for 'red' means for values just above and below .5 the 'red' component will be .25 .

Values in between pivot points are linearly interpolated by the function matplotlib.colors.LinearSegmentedColormap.

A complete (and ugly) example is given below: import pylab as mcdict = {'red'  :  ((0., 0., 0.), (0.5, 0.25, 0.25), (1., 1., 1.)),'green':  ((0., 1., 1.), (0.7, 0.0, 0.5), (1., 1., 1.)),'blue' :  ((0., 1., 1.), (0.5, 0.0, 0.0), (1., 1., 1.))}#generate the colormap with 1024 interpolated valuesmy_cmap = m.matplotlib.colors.LinearSegmentedColormap('my_colormap', cdict, 1024)#create a gaussianx = m.arange(0, 50 , 1 , m.Float)y = x[:,m.NewAxis]x0 = y0 = x.size // 2fwhm= x0/1.2z = m.exp(-4*m.log(2)*((x-x0)**2+(y-y0)**2)/fwhm**2)pcolormesh(z, cmap = my_cmap)colorbar()
The api is more for reference, rather than learning.

1. Thank you very much...you have very clearly explained what I was struggling to learn from terser sources.

Paul

### Flowing text in inkscape (Poster making)

You can flow text into arbitrary shapes in inkscape. (From a hint here).

You simply create a text box, type your text into it, create a frame with some drawing tool, select both the text box and the frame (click and shift) and then go to text->flow into frame.

UPDATE:

Trying to enter sentence so that text forms the number three...any ideas?
The solution:
Type '3' using the text toolConvert to path using object->pathSize as necessaryRemove fillUngroupType in actual text in new text boxSelect the text and the '3' pathFlow the text

### Latex math: Vertical bar

Like that used for indicating the evaluation of integrals between limits:

\bigg|

as in

\frac{\rho}{4\pi}\left(-\frac{1}{r}\right)\bigg|_{r_{0}}^{\infty}

from a hint here from robphy

### Calculating confidence intervals: straight Python is as good as scipy.stats.scoreatpercentile

UPDATE:
I would say the most efficient AND readable way of working out confidence intervals from bootstraps is:

numpy.percentile(r,[2.5,50,97.5],axis=1)

Where r is a n x b array where n are different runs (e.g different data sets) and b are the individual bootstraps within a run. This code returns the 95% CIs as three numpy arrays.

Confidence intervals can be computed by bootstrapping the calculation of a descriptive statistic and then finding the appropriate percentiles of the data. I saw that scipy.stats has a built in percentile function and assumed that it would work really fast because (presumably) the code is in C. I was using a simple minded Python/Numpy implementation by first sorting and then picking the appropriate percentile data. I thought this was going to be inefficient timewise and decided that using scipy.stats.scoreatpercentile was going to be blazing fast because
It was native C It was vectorized - I could compute the CIs for multiple bootstrap runs at the same time …