publiplots.resolve_hatches

publiplots.resolve_hatches(hatches=None, n_hatches=None, reverse=False, mode=None)[source]

Resolve hatch patterns for plotting.

This is a helper function that standardizes hatch pattern specifications into a concrete list of patterns. It handles pattern cycling for arbitrary numbers of categories and supports pattern reversal.

Parameters:
  • hatches (list of str, optional) – List of hatch patterns to use. If None, uses default patterns from get_hatch_patterns() based on the current or specified mode.

  • n_hatches (int, optional) – Number of hatch patterns to return. If provided, patterns will be cycled to reach this count. If None, returns all patterns.

  • reverse (bool, default=False) – Whether to reverse the pattern order. Useful for changing visual hierarchy or matching reversed color palettes.

  • mode (int, optional) – Pattern density mode (1, 2, or 3). If None, uses current global mode. Only applicable when hatches is None.

Returns:

List of resolved hatch pattern strings.

Return type:

List[str]

Examples

Get default patterns: >>> patterns = resolve_hatches() >>> len(patterns) 8

Get exactly 5 patterns with cycling: >>> patterns = resolve_hatches(n_hatches=5) >>> len(patterns) 5

Use custom patterns: >>> patterns = resolve_hatches(hatches=[‘///’, ‘|||’, ‘xxx’], n_hatches=7)

Get reversed patterns: >>> patterns = resolve_hatches(n_hatches=4, reverse=True)

Use specific mode: >>> patterns = resolve_hatches(mode=3, n_hatches=5) # Dense patterns

See also

resolve_hatch_map

Create a mapping from values to patterns

get_hatch_patterns

Get patterns for a specific mode