# How to rescale the colorfunction?

I have a data file which has 3 columns (let's call them x, y, p). Here x and y columns represent the co-ordinates in the 2-d plane while the third column p represent the probability of an event happening at the value of (x,y). I want to make a 2-d ListPlot such that the color of a point at (x,y) is decided by the value of p at that point. Since I have 100 such points in my file, the probability p at each points are quite small (as total probability add up to 1). So I need to rescale the colorfunction in a clever way so that I get a smoothly color varying plot. Can someone help me about how to rescale the colorfunction?

• You can rescale your p list to run on {0, 1} and use this in ColorData: ColorData["TemperatureMap"]/@Rescale[p,MinMax[p],{0,1}].
– Alx
Commented Sep 29, 2019 at 12:55

Like Alx said in a comment, what you have to do is to rescale your data before you pass it to the color function, which you can do with Rescale.

You can use the maximum value in the list as the upper value, and the minimum value in the list as the lower value, but sometimes it is preferable to scale the color function to a certain range so that the color function stays consistent if the data changes. I will show how to do that:

xy = RandomReal[1, {100, 2}];
p = RandomReal[{0, 0.1}, 100];
cf = ColorData["TemperatureMap"]@Rescale[#, {0, 0.1}] &;
colors = cf /@ p;