Rhythm of the lines¶
rhythm_plot(patterns, stressed, ax=None, labels=None)
A row per line and a cell per syllable of its pattern, numbered from 1: the stressed syllables in one color, the others in another, nothing past the end of a line, so that the columns of a meter and the lines that break it show at a glance.
| Parameter | Type | Default | Description |
|---|---|---|---|
patterns |
list[str] |
- | Patterns of the lines, a character per syllable |
stressed |
str |
- | Character of a stressed syllable in the patterns |
ax |
Axes |
None |
Axes for the plot |
labels |
dict[str, str] |
None |
Labels over the defaults: title, xlabel, ylabel, stressed, unstressed (the legend) |
Patterns that are not a list of strings raise SourceTypeError, no lines SourceError; a stressed that is not one character, labels that merge_labels refuses and an ax that is not a matplotlib Axes raise ParameterError.
It is the function of the anyTS core. The default labels are the English ones of VISUALIZER_LABELS in anyts.constants; labels replaces any of them. The patterns of the lines are the patterns of VerseStats, and the character of a stressed syllable is PATTERN_STRESSED of ests.verse_stats.
Caupolicán by Rubén Darío from the sonnets, in alexandrines: every line stresses the sixth and the thirteenth syllables, the ends of its two hemistichs.
from ests import VerseStats
from ests.datasets import SpanishSonnets
from ests.verse_stats import PATTERN_STRESSED
from ests.visualizers import rhythm_plot
ss = SpanishSonnets()
ss.download()
sonnet = next(
record["text"] for record in ss.get_records(author="darío") if record["title"] == "CAUPOLICÁN"
)
vs = VerseStats(sonnet)
rhythm_plot(vs.patterns, PATTERN_STRESSED)
