# What is the logarithmic color scales?(not logarithmic axes) [duplicate]

I have some density plots and an "advise". What does it mean? " I also strongly recommend switching the color scales in this figure from linear to log, to make it even easier to see the region of instability." What is the Log color scale? How can I do this? Note that, I think this is different with a density plot with logarithmic scales iv axis. Tnx.

• @corey979: No it is not my question! – Perfect Fluid Jun 23 '18 at 13:14
• Due to the lack of a concrete example, I can only suggest that you use the ColorFunction option to change the scaling. E.g., you can use ColorFunction -> ColorData["DarkRainbow"]@*Log10, where ColorData["DarkRainbow"] stands for just any color function. – Henrik Schumacher Jun 23 '18 at 13:18
• @corey979: I used this. The bar legend is disappeared! and all the figure goes gray :/ – Perfect Fluid Jun 23 '18 at 13:34

dp1 = DensityPlot[x^2 + y^2, {x, 10, 100}, {y, 10, 100},
ColorFunction -> "Rainbow", ImageSize -> 250 ] ;


In DensityPlot[f, ...] the argument of func in ColorFunction > func is the f. So using the option ScalingFunctions -> {None, None, "Log"} makes the coloring logarithmic.

dp2 = DensityPlot[x^2 + y^2, {x, 10, 100}, {y, 10, 100},
ColorFunction -> "Rainbow",
ScalingFunctions -> {None, None, "Log"}, ImageSize -> 250] ;


Alternatively, you can use scaled ColorFunction together with the option ColorFunctionScaling -> False to get the same result.

dp3 = DensityPlot[x^2 + y^2, {x, 10, 100}, {y, 10, 100},
ColorFunction -> (ColorData[{"Rainbow", {Log@200, Log@20000}}][
Log@#] &), ColorFunctionScaling -> False, ImageSize -> 250];

Row[{dp1, dp2, dp3}]

• Does it related to the colors only? Or effects on the axis scales too? In fact, I have some negative values of the function in the density plot. Is it possible to have a logarithmic scaling yet?! – Perfect Fluid Jun 23 '18 at 13:27
• @PerfectFluid, it does not affect the axes scales. Color function argument is the scaled value of the function f in the first argument of DensityPlot; so using Log scaling on the f values only changes the values supplied to ColorFunction. With negative and zero values you can't use log scaling (i think those values will be cropped.) Based on the graphs in your other question, I think the referee's suggestion doesn't make much sense. – kglr Jun 23 '18 at 13:39
• Thank you so much. – Perfect Fluid Jun 23 '18 at 13:43
• Dear @kglr, I just installed a higher version of Mma, and scaling functions is active now. However, some parts of the density plot are white! I have tested the points of this region and did not equal to zero. What is the reason of this white area?! – Perfect Fluid Jun 23 '18 at 14:32
• @perfectfluid: be sure that you enable PlotRange->Full, if not mathematica cuts out parts of your result that it deems too large or too small to fit on the plot. – ptaels Oct 17 '19 at 11:59