1
$\begingroup$

I'm using Ruleplot[] to plot the rules of my cellular automota. I'm using multiple 'colors' (= number of states $k$ ) and I want to color them a different color than the default grayscale. The documentation says to use ColorRules. In ColorRules I found that if no rules are found ColorFunction is used as default. I want to use ColorFunction -> "Rainbow" but when I try it I get an error.

RulePlot[CellularAutomaton[{5^3, 5, {1, 1}}], ColorRules -> {}, 
    ColorFunction -> "Rainbow"]

enter image description here

I don't want to manually provide ColorRules->{0 -> Red, 1 -> Orange, etc} because when I change $k$ I don't want to change all the colors by hand.

$\endgroup$
  • 1
    $\begingroup$ does RulePlot[CellularAutomaton[{5^3, 5, {1, 1}}]] /. {GrayLevel[g_], r_Rectangle} :> {ColorData["Rainbow"][g], r} give what you need? $\endgroup$ – kglr Sep 23 at 21:31
  • $\begingroup$ Yes it does! It feels a bit like an ugly solution but it does the trick. I will keep this question open in case a more proper solution comes by but in the meantime this will keep me happy. $\endgroup$ – AccidentalTaylorExpansion Sep 23 at 21:42
2
$\begingroup$

Use ColorData[name] as the setting for ColorFunction:

RulePlot[CellularAutomaton[{5^3, 5, {1, 1}}], Appearance -> "Arrow", 
 ImageSize -> Large, ColorFunction -> ColorData["Rainbow"]]

enter image description here

Use ColorFunction -> ColorData["TemperatureMap"] to get

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.