publiplots.get_hatch_patterns

publiplots.get_hatch_patterns(mode=None)[source]

Get hatch patterns for a specified density mode.

The density mode controls how dense / sparse the hatch patterns are by multiplying the base patterns:

  • Mode 1: base × 1 (e.g., '/', '.' becomes '/', '.').

  • Mode 2: base × 2 (e.g., '/', '.' becomes '//', '..').

  • Mode 3: base × 3 (e.g., '/', '.' becomes '///', '...').

  • Mode 4: base × 4 (e.g., '/', '.' becomes '////', '....').

Denser patterns provide stronger visual distinction but may appear cluttered in small plot areas. Mode 1 is recommended for most use cases.

Parameters:

mode (int, optional) – Pattern density mode. Must be 1, 2, 3, or 4. If None, uses the current global mode from pp.rcParams["hatch_mode"].

Returns:

Hatch pattern strings of the requested density.

Return type:

list of str

Raises:

ValueError – If mode is not 1, 2, 3, or 4.

Examples

Get mode 1 patterns:

>>> import publiplots as pp
>>> patterns = pp.get_hatch_patterns(mode=1)
>>> patterns[1]
'/'

Get mode 3 (dense) patterns:

>>> patterns = pp.get_hatch_patterns(mode=3)
>>> patterns[1]
'///'

Use the current global mode:

>>> pp.set_hatch_mode(2)
>>> patterns = pp.get_hatch_patterns()  # Uses mode 2

See also

set_hatch_mode

Set the global hatch density mode.

get_hatch_mode

Read the current global hatch density mode.

resolve_hatches

Produce a cycled list of patterns for N categories.