From: Reinier H. <re...@he...> - 2009-08-16 17:04:48
|
Hi Eric, all, I've attached a new patch where I also allow two extra ways to define color maps: - by specifying (value, color) pairs, giving a linearly interpolated map. - by specifying functions (gnuplot default functions are included) I've added a few colormaps: afmhot, bwr, brg, gnuplot, gnuplot2, ocean, rainbow, seismic, terrain I refactored a few others: flag, prism, gist_gray, gist_heat, gist_rainbow, gist_stern, gist_yarg. This saves about ~3000 lines... (And the differences are very minor) You can compare them with the old scales by running examples/pylab_examples/show_colormaps.py both with and without the attached patch. What do you think? If it's ok, shall I push to trunk or v99? Regards, Reinier On Thu, Aug 13, 2009 at 1:16 AM, Eric Firing<ef...@ha...> wrote: > Reinier Heeres wrote: >> >> Hi all, >> >> I would like to propose the attached patch to be able to use a gamma >> value for color maps. This will make it simple to make your color >> scale more 'sensitive' at the bottom or at the top, as can be seen in >> the attached example. This could in principle also be solved by adding >> a gamma normalizer, but I think that applying it to a color map is >> quite coming practice, so in this case the preferred way. > > Your patch looks reasonable to me. >> >> I'd also like to add a few extra color maps (at least one plain >> blue-white-red and one with darker shades at the high and low ends, as > > Good. > >> in the attachment). I also remember a particular one ('terrain') in a >> measurement program called 'Igor' that would be nice. > > Is there any potential licensing problem? I hope not. I presume you would > copy the effect, not any particular set of numbers extracted from Igor. > >> >> Looking at _cm.py, I would guess that could be done a bit more >> efficient than the current 5880 lines as well by just specifying a few >> colors and using LinearSegmentedColormap.from_list(). Is it ok if I >> try to refactor that? > > You mean take the colormaps that have a huge number of color dictionary > entries in _cm.py, and subsample them down to something reasonable? Please > do! I always hated those blocks of numbers, but never enough to motivate me > to do something about them other than a little reformatting. > > It sounds like you are talking about going farther than that, which might be > fine but might make things more complicated. As it is now, all the built-in > colormaps are associated with color dictionaries for direct use in > LinearSegmentedColormap. If you make two styles, one based on the > dictionaries (which allows discontinuities) and one based on from_list > (which does not), then you need to keep track of which is which. Is it > worth it? I am inclined to stick with the cdict approach. > > It looks like an obvious addition would a function that takes a list of > breakpoints (starting with 0 and ending with 1) and a matching list of > colors and generates the corresponding cdict for continuous mapping. > > Eric > >> >> Let me know what you think. >> >> Cheers, > -- Reinier Heeres Tel: +31 6 10852639 |