I am using a javascript ploting package called plotly and I use that to generate a contour map. In that package you define a rangeMin, rangeMax, and binSize, and you give it a color map, e.g.:
[["0", "rgb(0,0,0)"], ["0.3", "rgb(230,0,0)"], ["0.6", "rgb(255,210,0)"], ["1", "rgb(255,255,255)"]] This specifies the color you want at the endpoints of the range, and at the 1/3 and 2/3 points. Given the range and binSize plotly calculates the number of bins and distributes the color uniformly across the range, coloring the contour map appropriately given the data. I have another legacy map not generated with plotly and I want the colors of that to match the plotly map. In the legacy map I have the rangeMin and rangeMax and the binSize (although the binSize is not currently used). It currently determines the color for each value like this, in python: COLORS = ('#ff9', '#ff0', '#fc0', '#f90', '#f60', '#f00', '#930', '#800000') normal = (value - rangeMin) / (value_max - rangeMax) ordinal = int(normal * len(COLORS)) if ordinal == len(self.COLORS): ordinal -= 1 color = COLORS[ordinal] I am looking for some advice on how I can modify this to generate the same colors as plotly would, given the same data set and range and bin size. -- https://mail.python.org/mailman/listinfo/python-list