0
$\begingroup$

If I want to ArrayPlot with color changes at an interval of orders of magnitude, how could I do it?

I have an array where some of the values are very small and some of the values are very large, and I want small values could plot a clear area. In other words, I want 0-10 values of matrix to correspond to 0-0.25 of color,10-100 to 0.25-0.5 and so on. For example the picture as bellow. Color Range from 0-10-100-1000 change continuously.

enter image description here

the answer here show the way to change discontinuously. But I want to change continuously.

I tried Rescale but it doesn't feel practical, a lot of the color is compressed. The following code is just for the sake of explanation, but actually my matrix is so large that the graph looks continuous.

a = RandomReal[{0, 1000}, {50, 50}];
ArrayPlot[a, 
 ColorFunction -> (ColorData["SunsetColors"][
     Rescale[ Log[#], {0, Log[1000]}, {0, 1}]] &), 
 ColorFunctionScaling -> False, PlotLegends -> Automatic]

enter image description here

a = RandomReal[{0, 1000}, {50, 50}];
ArrayPlot[a, ColorFunction -> (ColorData["SunsetColors"]), 
 PlotLegends -> Automatic]

enter image description here

$\endgroup$
3
  • $\begingroup$ @xzczd I think it's not. I want 0-10 values of matrix to correspond to 0-0.25 of color,10-100 to 0.25-0.5 and so on. I think what he does is change the value of BarLegend $\endgroup$ – shrocat May 8 at 11:55
  • 1
    $\begingroup$ Strongly related, if not duplicate: mathematica.stackexchange.com/q/36830/1871 $\endgroup$ – xzczd May 8 at 12:03
  • $\begingroup$ @xzczd Wow, thank you. I've been looking for it all afternoon and get nothing. w(゚Д゚)w $\endgroup$ – shrocat May 8 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.