factoriax.analysis.categories

factoriax.analysis.categories#

Group the engine’s actions and items into colored categories.

Plot code asks two questions of this module. Which category does this action or item belong to, and what color is that category? The answers drive the bands of a stacked area chart and the node fills of the recipe diagram.

Every member of a category shares the base color of that category. The color therefore gives the category, and the label gives the member. There is no separate shade for each member.

The action groups are written out by hand, because a category such as “Movement” has no enum of its own. The item groups come from the engine’s Resource, HalfFabricate, and Machine enums, so they cannot drift from the item table in constants.py.

Every key in the returned maps is the upper-case name of an ItemType or Action member, such as IRON_PLATE. Colors are hex strings such as "#2ca02c".

factoriax.analysis.categories.category_palette() → dict[str, str]#

Map every item category name to its base color.

Use this for a legend, where one entry stands for a whole category. Use item_palette() to color a single item.

Returns:

{category_label: hex}, such as {"Machines": "#2ca02c"}. The insertion order follows _CATEGORY_SOURCES, so a legend built from it keeps a stable order between runs.

Return type:

dict

factoriax.analysis.categories.item_palette() → dict[str, str]#

Map every item name to the fill color of its category.

Every item in a category shares the base color of that category. The color therefore gives the category and nothing more. The label separates one item from another. There is no shade for each item, and this is deliberate. A reader cannot rank twelve shades of one hue, but a reader can read a name.

Returns:

{item_name: hex}. The key is the upper-case ItemType member name, such as IRON_PLATE. An item outside the three category enums is absent, so the caller needs a fallback color.

Return type:

dict

factoriax.analysis.categories.item_to_category() → dict[str, str]#

Map every item name to the name of its category.

This is the inverse view of ITEM_GROUPS. Use it to decide which legend entry an item belongs under.

Returns:

{item_name: category_label}. The key is the upper-case ItemType member name, such as IRON_PLATE. An item outside the three category enums is absent, so a caller must handle a missing key.

Return type:

dict