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$
2
  • 1
    $\begingroup$ does RulePlot[CellularAutomaton[{5^3, 5, {1, 1}}]] /. {GrayLevel[g_], r_Rectangle} :> {ColorData["Rainbow"][g], r} give what you need? $\endgroup$
    – kglr
    Commented Sep 23, 2020 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$ Commented Sep 23, 2020 at 21:42

1 Answer 1

3
$\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

$\endgroup$
1
  • $\begingroup$ Thanks this is exactly what I meant $\endgroup$ Commented Sep 23, 2020 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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