ColorRules
セルの色を値からどのように決定するかを指定するオプションである.
ColorRules
ColorRules
セルの色を値からどのように決定するかを指定するオプションである.
詳細
- ColorRulesによって与えられる規則は,各セルの値に適用される.
- ColorRulesの規則はパターンを含むことができる.
- ColorRulesを適用した結果がNoneの場合は,背景色が使われる.
- ColorRulesの規則が何も適用されなかった場合,色の決定にはColorFunctionが使われる.
- デフォルト設定のColorRules->Automaticでは,ColorRulesの代りにColorFunction->f という明示的な設定が使われる.
例題
すべて開く すべて閉じる例 (4)
ArrayPlotで色規則を使う:
ArrayPlot[{{a, 1}, {2, b}}, ColorRules -> {a -> Yellow, b -> Blue}]MatrixPlotで色規則を使う:
MatrixPlot[{{1, 0, 3}, {0, 2, 0}, {0, 0, 4}}, ColorRules -> {0 -> Yellow, _ -> Blue}]GeoRegionValuePlotに色の規則を使う:
GeoRegionValuePlot[{Entity["Country", "Netherlands"] -> 2, Entity["Country", "Greece"] -> 3, Entity["Country", "Spain"] -> 4}, ColorRules -> {2 -> Orange, 3 -> Blue, 4 -> Red}]Colorizeに色の規則を使う:
Colorize[MorphologicalComponents[[image]], ColorFunction -> "Rainbow", ColorRules -> {0 -> White}]スコープ (4)
ColorRulesはパターンを含むことができる:
ArrayPlot[{{1, 2, 3}, {4, 2, 1}, {2, 1, 3}}, ColorRules -> {1 -> Red, 2 -> Yellow, _ -> White}]明示的な色規則が適用されなければ,デフォルトのArrayPlotの色合いが適用される:
ArrayPlot[{{1, 2, 3}, {4, 2, 1}, {2, 1, 3}}, ColorRules -> {1 -> Red}]ArrayPlot[{{1, 2, 3}, {4, 2, 1}, {2, 1, 3}}, ColorRules -> {1 -> Red}, ColorFunction -> "IslandColors"]Noneと指定された場合は背景色で描画される:
ArrayPlot[{{1, 2, 3}, {4, 2, 1}, {2, 1, 3}}, ColorRules -> {3 | 4 -> None}, Background -> Blue]アプリケーション (3)
Table[ArrayPlot[Table[Mod[f[i, j], 5], {i, 0, 40}, {j, 0, 40}], ColorRules -> {0 -> White, 1 -> Yellow, 2 -> Orange, 3 -> Pink, 4 -> Red}], {f, {Plus, Subtract, Times}}]ArrayPlot[Table[GCD[i, j], {i, 20}, {j, 20}], ColorRules -> {1 -> Red}]ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 50], ColorRules -> {0 -> Black, 1 -> Red, 2 -> Yellow}]履歴
2004 で導入 (5.1)
テキスト
Wolfram Research (2004), ColorRules, Wolfram言語関数, https://reference.wolfram.com/language/ref/ColorRules.html.
CMS
Wolfram Language. 2004. "ColorRules." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ColorRules.html.
APA
Wolfram Language. (2004). ColorRules. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorRules.html
BibTeX
@misc{reference.wolfram_2026_colorrules, author="Wolfram Research", title="{ColorRules}", year="2004", howpublished="\url{https://reference.wolfram.com/language/ref/ColorRules.html}", note=[Accessed: 17-July-2026]}
BibLaTeX
@online{reference.wolfram_2026_colorrules, organization={Wolfram Research}, title={ColorRules}, year={2004}, url={https://reference.wolfram.com/language/ref/ColorRules.html}, note=[Accessed: 17-July-2026]}