publiplots.resolve_hatches¶
- publiplots.resolve_hatches(hatches=None, n_hatches=None, reverse=False, mode=None)[source]¶
Resolve hatch patterns for plotting.
Helper that standardises hatch pattern specifications into a concrete list. Handles pattern cycling for arbitrary category counts and supports reversal.
- Parameters:
hatches (list of str, optional) – Hatch patterns to use. If
None, pulls patterns fromget_hatch_patterns()at the current or specified mode.n_hatches (int, optional) – Number of patterns to return. If provided, the source list is cycled to reach this count. If
None, returns the full source list.reverse (bool, default
False) – Whether to reverse the final pattern order. Useful for matching a reversed color palette.mode (int, optional) – Pattern density mode (
1,2,3, or4). IfNone, uses the current global mode. Only applicable whenhatchesisNone.
- Returns:
Resolved hatch pattern strings.
- Return type:
Examples
Get default patterns:
>>> import publiplots as pp >>> patterns = pp.resolve_hatches() >>> len(patterns) 8
Get exactly 5 patterns with cycling:
>>> patterns = pp.resolve_hatches(n_hatches=5) >>> len(patterns) 5
Use custom patterns:
>>> patterns = pp.resolve_hatches(hatches=['///', '|||', 'xxx'], n_hatches=7)Get reversed patterns:
>>> patterns = pp.resolve_hatches(n_hatches=4, reverse=True)Use a specific density mode:
>>> patterns = pp.resolve_hatches(mode=3, n_hatches=5)See also
resolve_hatch_mapCreate a mapping from values to patterns.
get_hatch_patternsGet patterns for a specific mode.
set_hatch_modeSet the global hatch density mode.