label

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.label" { graph [label="abjad.label"]; node [color=1]; "abjad.label.ColorMap" [URL="../api/abjad/label.html#abjad.label.ColorMap", color=black, fontcolor=white, label="Color\nMap", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.label.ColorMap"; }


Classes

ColorMap

Color map.

class abjad.label.ColorMap(colors=None, pitch_iterables=None)[source]

Color map.

Maps pitch-classes to red, green and blue:

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> color_map
ColorMap(colors=['#red', '#green', '#blue'], pitch_iterables=[[-8, 2, 10, 21], [0, 11, 32, 41], [15, 25, 42, 43]])

Attributes Summary

__eq__

Return self==value.

__getitem__

Gets pitch_class color.

__hash__

Makes hash.

__post_init__

__repr__

Return repr(self).

get

Gets key from color map.

is_twelve_tone_complete

Is true when color map contains all 12-ET pitch-classes.

is_twenty_four_tone_complete

Is true when color map contains all 24-ET pitch-classes.

pairs

Gets pairs.


Special methods

overridden __eq__(other)

Return self==value.

__getitem__(pitch_class)[source]

Gets pitch_class color.

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> color_map[11]
'#green'
Return type:

str

overridden __hash__()[source]

Makes hash.

__post_init__()[source]
overridden __repr__()

Return repr(self).


Methods

get(key, alternative=None)[source]

Gets key from color map.

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> color_map.get(11)
'#green'

Returns alternative when key is not found.

Return type:

str


Read-only properties

is_twelve_tone_complete

Is true when color map contains all 12-ET pitch-classes.

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> color_map.is_twelve_tone_complete
True
is_twenty_four_tone_complete

Is true when color map contains all 24-ET pitch-classes.

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> color_map.is_twenty_four_tone_complete
False
pairs

Gets pairs.

>>> color_map = abjad.ColorMap(
...     colors=["#red", "#green", "#blue"],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...     ],
... )
>>> for pair in color_map.pairs:
...     pair
... 
(0, '#green')
(1, '#blue')
(2, '#red')
(3, '#blue')
(4, '#red')
(5, '#green')
(6, '#blue')
(7, '#blue')
(8, '#green')
(9, '#red')
(10, '#red')
(11, '#green')

Functions

by_selector

Colors leaves in argument by selector.

color_container

Colors contents of container.

color_leaves

Colors leaves in argument.

color_note_heads

Colors note note-heads.

remove_markup

Removes markup from leaves in argument.

vertical_moments

Labels vertical moments.

with_durations

Labels logical ties in argument with durations.

with_indices

Labels logical ties in argument with indices.

with_intervals

Labels consecutive notes in argument with intervals.

with_pitches

Labels logical ties in argument with pitches.

with_set_classes

Labels selections argument with set-classes.

with_start_offsets

Labels logical ties in argument with start offsets.

abjad.label.by_selector(argument, selector=None, colors=None, lone=False, *, deactivate=False, tag=None)[source]

Colors leaves in argument by selector.

Return type:

None

abjad.label.color_container(container, color='#red')[source]

Colors contents of container.

>>> staff = abjad.Staff("c'8 d'8")
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0])
>>> abjad.label.color_container(staff, "#red")
>>> abjad.show(staff)  
Return type:

None

abjad.label.color_leaves(argument, color='#red', *, deactivate=False, tag=None)[source]

Colors leaves in argument.

>>> staff = abjad.Staff("cs'8. r8. s8. <c' cs' a'>8.")
>>> abjad.label.color_leaves(staff, "#red")
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
Return type:

None

abjad.label.color_note_heads(argument, color_map={0: "#(x11-color 'red)", 1: "#(x11-color 'MediumBlue)", 2: "#(x11-color 'orange)", 3: "#(x11-color 'LightSlateBlue)", 4: "#(x11-color 'ForestGreen)", 5: "#(x11-color 'MediumOrchid)", 6: "#(x11-color 'firebrick)", 7: "#(x11-color 'DeepPink)", 8: "#(x11-color 'DarkOrange)", 9: "#(x11-color 'IndianRed)", 10: "#(x11-color 'CadetBlue)", 11: "#(x11-color 'SeaGreen)", 12: "#(x11-color 'LimeGreen)"})[source]

Colors note note-heads.

>>> chord = abjad.Chord([12, 14, 18, 21, 23], (1, 4))
>>> pitches = [[-12, -10, 4], [-2, 8, 11, 17], [19, 27, 30, 33, 37]]
>>> colors = ["#red", "#blue", "#green"]
>>> color_map = abjad.ColorMap(colors=colors, pitch_iterables=pitches)
>>> abjad.label.color_note_heads(chord, color_map)
>>> abjad.show(chord)  

Colors note note-head:

>>> note = abjad.Note("c'4")
>>> abjad.label.color_note_heads(note, color_map)
>>> abjad.show(note)  

Colors nothing:

>>> staff = abjad.Staff()
>>> abjad.label.color_note_heads(staff, color_map)

Colors note-heads:

>>> string = "c'8 cs'8 d'8 ds'8 e'8 f'8 fs'8 g'8 gs'8 a'8 as'8 b'8 c''8"
>>> staff = abjad.Staff(string)
>>> abjad.label.color_note_heads(staff)
>>> abjad.show(staff)  
Return type:

None

abjad.label.remove_markup(argument)[source]

Removes markup from leaves in argument.

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> abjad.label.with_pitches(staff)
>>> abjad.show(staff)  
>>> abjad.label.remove_markup(staff)
>>> abjad.show(staff)  
Return type:

None

abjad.label.vertical_moments(argument, direction=Vertical.UP, prototype=None, *, deactivate=False, tag=None)[source]

Labels vertical moments.

Labels indices:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> abjad.label.vertical_moments(staff_group)
>>> abjad.show(staff_group)  

Labels pitch numbers:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> abjad.label.vertical_moments(
...     staff_group,
...     prototype=abjad.NumberedPitch,
... )
>>> abjad.show(staff_group)  

Labels pitch-class numbers:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = abjad.NumberedPitchClass
>>> abjad.label.vertical_moments(staff_group, prototype=prototype)
>>> abjad.show(staff_group)  

Labels interval numbers:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = abjad.NumberedInterval
>>> abjad.label.vertical_moments(staff_group, prototype=prototype)
>>> abjad.show(staff_group)  

Labels interval-class numbers:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = abjad.NumberedIntervalClass
>>> abjad.label.vertical_moments(staff_group, prototype=prototype)
>>> abjad.show(staff_group)  

Labels interval-class vectors:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = abjad.pcollections.make_interval_class_vector
>>> abjad.label.vertical_moments(staff_group, prototype=prototype)
>>> abjad.show(staff_group)  

Labels set-classes:

>>> staff_group = abjad.StaffGroup([])
>>> staff = abjad.Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = abjad.Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = abjad.SetClass()
>>> abjad.label.vertical_moments(staff_group, prototype=prototype)
>>> abjad.show(staff_group)  

Set prototype to one of the classes shown above.

Returns none.

abjad.label.with_durations(argument, *, denominator=None, direction=Vertical.UP, in_seconds=False)[source]

Labels logical ties in argument with durations.

Labels logical tie durations:

>>> staff = abjad.Staff(r"c'4. d'8 ~ d'4. e'16 [ ef'16 ]")
>>> abjad.label.with_durations(staff)
>>> abjad.show(staff)  

Labels logical ties with preferred denominator:

>>> staff = abjad.Staff(r"c'4. d'8 ~ d'4. e'16 [ ef'16 ]")
>>> abjad.label.with_durations(staff, denominator=16)
>>> abjad.show(staff)  

Returns none.

abjad.label.with_indices(argument, direction=Vertical.UP, prototype=None)[source]

Labels logical ties in argument with indices.

Labels logical tie indices:

>>> staff = abjad.Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> abjad.label.with_indices(staff)
>>> abjad.override(staff).TextScript.staff_padding = 2
>>> abjad.show(staff)  

Labels note indices:

>>> staff = abjad.Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> abjad.label.with_indices(staff, prototype=abjad.Note)
>>> abjad.override(staff).TextScript.staff_padding = 2
>>> abjad.show(staff)  

Labels chord indices:

>>> staff = abjad.Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> abjad.label.with_indices(staff, prototype=abjad.Chord)
>>> abjad.override(staff).TextScript.staff_padding = 2
>>> abjad.show(staff)  

Labels leaf indices:

>>> staff = abjad.Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> abjad.label.with_indices(staff, prototype=abjad.Leaf)
>>> abjad.override(staff).TextScript.staff_padding = 2
>>> abjad.show(staff)  

Labels tuplet indices:

>>> tuplet = abjad.Tuplet((2, 3), "c'8 [ d'8 e'8 ]")
>>> tuplets = abjad.mutate.copy(tuplet, 4)
>>> staff = abjad.Staff(tuplets)
>>> abjad.label.with_indices(staff, prototype=abjad.Tuplet)
>>> abjad.override(staff).TextScript.staff_padding = 2
>>> abjad.show(staff)  
Return type:

None

abjad.label.with_intervals(argument, direction=Vertical.UP, prototype=None)[source]

Labels consecutive notes in argument with intervals.

Labels consecutive notes with interval names:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = abjad.makers.make_notes(pitch_numbers, [(1, 4)])
>>> staff = abjad.Staff(notes)
>>> abjad.label.with_intervals(staff, prototype=None)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels consecutive notes with interval-class names:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = abjad.makers.make_notes(pitch_numbers, [(1, 4)])
>>> staff = abjad.Staff(notes)
>>> prototype = abjad.NamedIntervalClass
>>> abjad.label.with_intervals(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels consecutive notes with interval numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = abjad.makers.make_notes(pitch_numbers, [(1, 4)])
>>> staff = abjad.Staff(notes)
>>> prototype = abjad.NumberedInterval
>>> abjad.label.with_intervals(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels consecutive notes with interval-class numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = abjad.makers.make_notes(pitch_numbers, [(1, 4)])
>>> staff = abjad.Staff(notes)
>>> prototype = abjad.NumberedIntervalClass
>>> abjad.label.with_intervals(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels consecutive notes with inversion-equivalent interval-class numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = abjad.makers.make_notes(pitch_numbers, [(1, 4)])
>>> staff = abjad.Staff(notes)
>>> prototype = abjad.NumberedInversionEquivalentIntervalClass
>>> abjad.label.with_intervals(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  
Return type:

None

abjad.label.with_pitches(argument, direction=Vertical.UP, locale=None, prototype=None)[source]

Labels logical ties in argument with pitches.

Labels logical ties with pitch names:

>>> staff = abjad.Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> abjad.label.with_pitches(staff, prototype=None)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels logical ties with American pitch names:

>>> staff = abjad.Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> abjad.label.with_pitches(staff, locale="us", prototype=None)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels logical ties with pitch numbers:

>>> staff = abjad.Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> prototype = abjad.NumberedPitch
>>> abjad.label.with_pitches(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels logical ties with pitch-class numbers:

>>> staff = abjad.Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> prototype = abjad.NumberedPitchClass
>>> abjad.label.with_pitches(staff, prototype=prototype)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.show(staff)  

Labels logical ties with pitch names (filtered by selection):

>>> voice = abjad.Voice("df''4 c''4 f'4 fs'4 d''4 ds''4")
>>> string = "Horizontal_bracket_engraver"
>>> voice.consists_commands.append(string)
>>> selections = [voice[:2], voice[-2:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> abjad.label.with_pitches(selections)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Labels logical ties with pitch numbers (filtered by selection):

>>> voice = abjad.Voice("df''4 c''4 f'4 fs'4 d''4 ds''4")
>>> voice.consists_commands.append("Horizontal_bracket_engraver")
>>> selections = [voice[:2], voice[-2:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> prototype = abjad.NumberedPitch
>>> abjad.label.with_pitches(selections, prototype=prototype)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Labels logical ties with pitch-class numbers (filtered by selection):

>>> voice = abjad.Voice("df''4 c''4 f'4 fs'4 d''4 ds''4")
>>> voice.consists_commands.append("Horizontal_bracket_engraver")
>>> selections = [voice[:2], voice[-2:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> prototype = abjad.NumberedPitchClass
>>> abjad.label.with_pitches(selections, prototype=prototype)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Returns none.

abjad.label.with_set_classes(argument, direction=Vertical.UP, prototype=None)[source]

Labels selections argument with set-classes.

Labels selections with Forte-ranked transposition-inversion set-classes:

>>> string = "df''8 c''8 bf'8 a'8 f'4. fs'8 g'8 b'8 d''2."
>>> voice = abjad.Voice(string)
>>> voice.consists_commands.append("Horizontal_bracket_engraver")
>>> selections = [voice[:4], voice[-4:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> abjad.label.with_set_classes(selections)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Labels selections with lex-ranked transposition-inversion set-classes:

>>> string = "df''8 c''8 bf'8 a'8 f'4. fs'8 g'8 b'8 d''2."
>>> voice = abjad.Voice(string)
>>> voice.consists_commands.append("Horizontal_bracket_engraver")
>>> selections = [voice[:4], voice[-4:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> prototype = abjad.SetClass(lex_rank=True)
>>> abjad.label.with_set_classes(selections, prototype=prototype)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Labels selections with transposition-only set-classes:

>>> string = "df''8 c''8 bf'8 a'8 f'4. fs'8 g'8 b'8 d''2."
>>> voice = abjad.Voice(string)
>>> voice.consists_commands.append("Horizontal_bracket_engraver")
>>> selections = [voice[:4], voice[-4:]]
>>> for selection in selections:
...     abjad.horizontal_bracket(selection)
... 
>>> prototype = abjad.SetClass(lex_rank=True, transposition_only=True)
>>> abjad.label.with_set_classes(selections, prototype=prototype)
>>> abjad.override(voice).HorizontalBracket.staff_padding = 3
>>> abjad.override(voice).TextScript.staff_padding = 2
>>> abjad.show(voice)  

Returns none.

abjad.label.with_start_offsets(argument, brackets=None, clock_time=None, direction=None, global_offset=None, markup_command=None)[source]

Labels logical ties in argument with start offsets.

Labels logical tie start offsets:

>>> string = r"\times 2/3 { c'4 d'4 e'4 ~ } e'4 ef'4"
>>> staff = abjad.Staff(string)
>>> abjad.label.with_start_offsets(staff, direction=abjad.UP)
Duration(1, 1)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.override(staff).TupletBracket.staff_padding = 0
>>> abjad.show(staff)  

Labels logical tie start offsets with clock time:

>>> staff = abjad.Staff(r"c'2 d' e' f'")
>>> score = abjad.Score([staff])
>>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60)
>>> abjad.attach(mark, staff[0])
>>> abjad.label.with_start_offsets(staff, clock_time=True)
Duration(8, 1)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.override(staff).TupletBracket.staff_padding = 0
>>> abjad.show(score)  

Labels logical tie start offsets with clock time and custom markup command. No PDF shown here because command is custom:

>>> staff = abjad.Staff(r"c'2 d' e' f'")
>>> score = abjad.Score([staff])
>>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60)
>>> abjad.attach(mark, staff[0])
>>> abjad.label.with_start_offsets(
...     staff,
...     clock_time=True,
...     markup_command=r"\dark_cyan_markup",
... )
Duration(8, 1)
>>> abjad.override(staff).TextScript.staff_padding = 4
>>> abjad.override(staff).TupletBracket.staff_padding = 0
>>> string = abjad.lilypond(score)
>>> print(string)
\new Score
<<
    \new Staff
    \with
    {
        \override TextScript.staff-padding = 4
        \override TupletBracket.staff-padding = 0
    }
    {
        \tempo 4=60
        c'2
        ^ \dark_cyan_markup { 0'00'' }
        d'2
        ^ \dark_cyan_markup { 0'02'' }
        e'2
        ^ \dark_cyan_markup { 0'04'' }
        f'2
        ^ \dark_cyan_markup { 0'06'' }
    }
>>

Returns total duration.