python,matplotlib,complex-numbers,arrow,color-mapping

import numpy as np import pylab as plt import itertools n = 13 roots = np.roots( [1,] + [0,]*(n-1) + [-1,] ) colors = itertools.cycle(['r', 'g', 'b', 'y']) plt.figure(figsize=(6,6)) for root in roots: plt.arrow(0,0,root.real,root.imag,ec=colors.next()) plt.xlim(-1.5,1.5) plt.ylim(-1.5,1.5) plt.show() The roots of unity are calculated in a manner similar to this answer....

First off, @tcaswell is right. You're probably wanting to animate a scatter plot. Using lots of plot calls for this will result in much worse performance than changing the collection that scatter returns. However, here's how you'd go about using multiple plot calls to do this: import numpy as np...

You could use np.vectorize, but as lolopop points out, this simply adds syntactic sugar; it does not make the implicit loop any faster: import colorsys import numpy as np rgb_to_hls = np.vectorize(colorsys.rgb_to_hls) hls_to_rgb = np.vectorize(colorsys.hls_to_rgb) arr = np.random.random((2, 2, 3)) * 255 r, g, b = arr[:, :, 0], arr[:,...

See if this works for you - [sorted_sumcols,idx] = sort(sum(A,2)) %// sum over columns and sort based on the sum Aout = A(idx,:) %// Aout holds the re-ordered rows of A Output - Aout = 1 1 1 1 1 2 1 2 1 2 1 1 1 1 3...

python,matplotlib,color-mapping

To explicitly set the color map range, you want to use the set_clim command: import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec plt.ion() conf_arr_hs = [[90, 74], [33, 131]] norm_conf_hs = [] for i in conf_arr_hs: a = 0 tmp_arr = [] a = sum(i, 0)...

python,image-processing,pygame,color-mapping,indexed-image

I actually figured out an answer in the course of asking it. Using pygame.Surface.set_palette_at(), I was able to extract the palette data from NewSurf (using NewSurf.get_palette(..) and an iterator to clear out that palette's blanks) and paste it onto the 'end' (that is, after the last non-blank RGBA index value)...

python,matplotlib,scatter-plot,colorbar,color-mapping

I ended up going with this. I'm not sure if it is the best way - if you have alternate suggestions perhaps I can learn from them for future use! cmap = matplotlib.colors.ListedColormap(['green', 'blue', 'red']) bounds=[0,125,200,400] cax = inset_axes(ax3, width="8%", height='70%', loc=4) cbar = matplotlib.colorbar.ColorbarBase(cax, cmap=cmap, boundaries=bounds) cax.yaxis.set_ticks_position('left') cbar.ax.set_yticklabels(['0', '125',...