Table Of Contents

Previous topic

music21.expressions

Next topic

music21.key

This Page

music21.graph

Object definitions for graphing and plotting Stream objects. The Graph object subclasses abstract fundamental graphing archetypes using the matplotlib library. The Plot object subclasses provide reusable approaches to graphing data and structures in Stream objects.

music21.graph.plotStream(streamObj, *args, **keywords)
Given a stream and any keyword configuration arguments, create and display a plot. Note: plots requires matplotib to be installed. Plot method can be specified as a second argument or by keyword. Available plots include the following: pitchSpace (PlotHistogramPitchSpace) pitchClass (PlotHistogramPitchClass) quarterLength (PlotHistogramQuarterLength) scatterPitchSpaceQuarterLength (PlotScatterPitchSpaceQuarterLength) scatterPitchClassQuarterLength (PlotScatterPitchClassQuarterLength) scatterPitchClassOffset (‘PlotScatterPitchClassOffset) pitchClassOffset (PlotHorizontalBarPitchSpaceOffset) pitchSpaceOffset (PlotHorizontalBarPitchClassOffset) pitchSpaceQuarterLengthCount (PlotScatterWeightedPitchSpaceQuarterLength) pitchClassQuarterLengthCount (PlotScatterWeightedPitchClassQuarterLength) 3DPitchSpaceQuarterLengthCount (Plot3DBarsPitchSpaceQuarterLength)

PlotHistogramPitchSpace

class music21.graph.PlotHistogramPitchSpace(streamObj, *args, **keywords)

A histogram of pitch space.

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotHistogramPitchSpace(s)
>>> p.id
'histogram-pitch'
>>> p.process() # with defaults and proper configuration, will open graph
_images/PlotHistogramPitchSpace.png

inherits from: PlotHistogram, PlotStream

PlotHistogramPitchSpace attributes

Attributes without Documentation: values

Attributes inherited from PlotHistogram: format

PlotHistogramPitchSpace properties

Properties inherited from PlotStream: id

PlotHistogramPitchSpace methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHistogramPitchClass

class music21.graph.PlotHistogramPitchClass(streamObj, *args, **keywords)

A histogram of pitch class

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotHistogramPitchClass(s)
>>> p.id
'histogram-pitchClass'
>>> p.process() # with defaults and proper configuration, will open graph
_images/PlotHistogramPitchClass.png

inherits from: PlotHistogram, PlotStream

PlotHistogramPitchClass attributes

Attributes without Documentation: values

Attributes inherited from PlotHistogram: format

PlotHistogramPitchClass properties

Properties inherited from PlotStream: id

PlotHistogramPitchClass methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHistogramQuarterLength

class music21.graph.PlotHistogramQuarterLength(streamObj, *args, **keywords)

A histogram of pitch class

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotHistogramQuarterLength(s)
>>> p.id
'histogram-quarterLength'
>>> p.process() # with defaults and proper configuration, will open graph
_images/PlotHistogramQuarterLength.png

inherits from: PlotHistogram, PlotStream

PlotHistogramQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from PlotHistogram: format

PlotHistogramQuarterLength properties

Properties inherited from PlotStream: id

PlotHistogramQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterPitchSpaceQuarterLength

class music21.graph.PlotScatterPitchSpaceQuarterLength(streamObj, *args, **keywords)

A scatter plot of pitch space and quarter length

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotScatterPitchSpaceQuarterLength(s)
>>> p.id
'scatter-pitch-quarterLength'
>>> p.process()
_images/PlotScatterPitchSpaceQuarterLength.png

inherits from: PlotScatter, PlotStream

PlotScatterPitchSpaceQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from PlotScatter: format

PlotScatterPitchSpaceQuarterLength properties

Properties inherited from PlotStream: id

PlotScatterPitchSpaceQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterPitchClassQuarterLength

class music21.graph.PlotScatterPitchClassQuarterLength(streamObj, *args, **keywords)

A scatter plot of pitch class and quarter length

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotScatterPitchClassQuarterLength(s)
>>> p.id
'scatter-pitchClass-quarterLength'
>>> p.process()
_images/PlotScatterPitchClassQuarterLength.png

inherits from: PlotScatter, PlotStream

PlotScatterPitchClassQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from PlotScatter: format

PlotScatterPitchClassQuarterLength properties

Properties inherited from PlotStream: id

PlotScatterPitchClassQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterPitchClassOffset

class music21.graph.PlotScatterPitchClassOffset(streamObj, *args, **keywords)

A scatter plot of pitch class and offset

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotScatterPitchClassOffset(s)
>>> p.id
'scatter-pitchClass-offset'
>>> p.process()
_images/PlotScatterPitchClassOffset.png

inherits from: PlotScatter, PlotStream

PlotScatterPitchClassOffset attributes

Attributes without Documentation: values

Attributes inherited from PlotScatter: format

PlotScatterPitchClassOffset properties

Properties inherited from PlotStream: id

PlotScatterPitchClassOffset methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHorizontalBarPitchSpaceOffset

class music21.graph.PlotHorizontalBarPitchSpaceOffset(streamObj, *args, **keywords)

A graph of events, sorted by pitch space, over time

>>> from music21 import *
>>> s = corpus.parseWork('bach/bwv57.8')
>>> p = graph.PlotHorizontalBarPitchSpaceOffset(s)
>>> p.id
'horizontalBar-pitch-offset'
>>> p.process() # with defaults and proper configuration, will open graph
_images/PlotHorizontalBarPitchSpaceOffset.png

inherits from: PlotHorizontalBar, PlotStream

PlotHorizontalBarPitchSpaceOffset attributes

Attributes without Documentation: values

Attributes inherited from PlotHorizontalBar: format

PlotHorizontalBarPitchSpaceOffset properties

Properties inherited from PlotStream: id

PlotHorizontalBarPitchSpaceOffset methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHorizontalBarPitchClassOffset

class music21.graph.PlotHorizontalBarPitchClassOffset(streamObj, *args, **keywords)

A graph of events, sorted by pitch class, over time

_images/PlotHorizontalBarPitchClassOffset.png

inherits from: PlotHorizontalBar, PlotStream

PlotHorizontalBarPitchClassOffset attributes

Attributes without Documentation: values

Attributes inherited from PlotHorizontalBar: format

PlotHorizontalBarPitchClassOffset properties

Properties inherited from PlotStream: id

PlotHorizontalBarPitchClassOffset methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterWeightedPitchSpaceQuarterLength

class music21.graph.PlotScatterWeightedPitchSpaceQuarterLength(streamObj, *args, **keywords)

A graph of event, sorted by pitch, over time

_images/PlotScatterWeightedPitchSpaceQuarterLength.png

inherits from: PlotScatterWeighted, PlotStream

PlotScatterWeightedPitchSpaceQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from PlotScatterWeighted: format

PlotScatterWeightedPitchSpaceQuarterLength properties

Properties inherited from PlotStream: id

PlotScatterWeightedPitchSpaceQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterWeightedPitchClassQuarterLength

class music21.graph.PlotScatterWeightedPitchClassQuarterLength(streamObj, *args, **keywords)

A graph of event, sorted by pitch class, over time.

_images/PlotScatterWeightedPitchClassQuarterLength.png

inherits from: PlotScatterWeighted, PlotStream

PlotScatterWeightedPitchClassQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from PlotScatterWeighted: format

PlotScatterWeightedPitchClassQuarterLength properties

Properties inherited from PlotStream: id

PlotScatterWeightedPitchClassQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

Plot3DBarsPitchSpaceQuarterLength

class music21.graph.Plot3DBarsPitchSpaceQuarterLength(streamObj, *args, **keywords)

A scatter plot of pitch and quarter length

>>> from music21 import *
>>> from music21.musicxml import testFiles
>>> s = converter.parse(testFiles.mozartTrioK581Excerpt)
>>> p = graph.Plot3DBarsPitchSpaceQuarterLength(s)
>>> p.id
'3dBars-pitch-quarterLength'
>>> p.process() # with defaults and proper configuration, will open graph
_images/Plot3DBarsPitchSpaceQuarterLength.png

inherits from: Plot3DBars, PlotStream

Plot3DBarsPitchSpaceQuarterLength attributes

Attributes without Documentation: values

Attributes inherited from Plot3DBars: format

Plot3DBarsPitchSpaceQuarterLength properties

Properties inherited from PlotStream: id

Plot3DBarsPitchSpaceQuarterLength methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

Graph

class music21.graph.Graph(*args, **keywords)

An object representing a graph or plot, automating the creation and configuration of this graph in matplotlib. Graph objects do not manipulate Streams or other music21 data; they only manipulate raw data formatted for each Graph subclass. Numerous keyword arguments can be provided for configuration: alpha, colorBackgroundData, colorBackgroundFigure, colorGrid, title, doneAction, figureSize, colors, tickFontSize, titleFontSize, labelFontSize, fontFamily. The doneAction determines what happens after graph processing: either write a file (‘write’), open an interactive GUI browser (‘show’) or None (do processing but do not write output.

A base-class for basic setup of graphs, abstracting functionality provided by matplotlib. Optional keyword arguments: alpha, colorBackgroundData, colorBackgroundFigure, colorGrid, title, doneAction, figureSize, tickFontSize, titleFontSize, labelFontSize, fontFamily

>>> a = Graph(title='green')

Graph attributes

axis
dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Attributes without Documentation: fontFamily, doneAction, title, colorBackgroundFigure, colors, tickFontSize, colorGrid, figureSize, colorBackgroundData, axisKeys, grid, titleFontSize, alpha, labelFontSize, data

Graph methods

done(fp=None)
Implement the desired doneAction, after data processing
process()
process data and prepare plot
setAxisLabel(axisKey, label)
No documentation.
setAxisRange(axisKey, valueRange, pad=False)
No documentation.
setData(data)
No documentation.
setDoneAction(action)
No documentation.
setFigureSize(figSize)
No documentation.
setTicks(axisKey, pairs)
paris are positions and labels
setTitle(title)
No documentation.
show()
Calls the show() method of the matplotlib plot. For most matplotlib back ends, this will open a GUI window with the desired graph.
write(fp=None)
Writes the graph to a file. If no file path is given, a temporary file is used.

Graph3DPolygonBars

class music21.graph.Graph3DPolygonBars(*args, **keywords)

Graph multiple parallel bar graphs in 3D. This draws bars with polygons, a temporary alternative to using Graph3DBars, above. Note: Due to matplotib issue Axis ticks do not seem to be adjustable without distorting the graph.

>>> from music21 import *
>>> g = graph.Graph3DPolygonBars()
>>> data = {1:[], 2:[], 3:[]}
>>> for i in range(len(data.keys())):
...    q = [(x, random.choice(range(10*(i+1)))) for x in range(20)]
...    data[data.keys()[i]] = q
>>> g.setData(data)
>>> g.process()
_images/Graph3DPolygonBars.png

inherits from: Graph

Graph3DPolygonBars attributes

Attributes without Documentation: barWidth

Attributes inherited from Graph: fontFamily, doneAction, title, colorBackgroundFigure, colors, tickFontSize, colorGrid, figureSize, colorBackgroundData, axisKeys, grid, titleFontSize, alpha, labelFontSize, data, axis

Graph3DPolygonBars methods

process()
No documentation.

Methods inherited from Graph: done(), setAxisLabel(), setAxisRange(), setData(), setDoneAction(), setFigureSize(), setTicks(), setTitle(), show(), write()

GraphColorGrid

class music21.graph.GraphColorGrid(*args, **keywords)

Grid of discrete colored “blocks” to visualize results of a windowed analysis routine. Data is provided as a list of lists of colors, where colors are specified as a hex triplet, or the common HTML color codes, and based on analysis-specific mapping of colors to results.

>>> a = GraphColorGrid(doneAction=None)
>>> data = [['#525252', '#5f5f5f', '#797979', '#858585', '#727272', '#6c6c6c', '#8c8c8c', '#8c8c8c', '#6c6c6c', '#999999', '#999999', '#797979', '#6c6c6c', '#5f5f5f', '#525252', '#464646', '#3f3f3f', '#3f3f3f', '#4c4c4c', '#4c4c4c', '#797979', '#797979', '#4c4c4c', '#4c4c4c', '#525252', '#5f5f5f', '#797979', '#858585', '#727272', '#6c6c6c'], ['#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#797979', '#6c6c6c', '#5f5f5f', '#5f5f5f', '#858585', '#797979', '#797979', '#797979', '#797979', '#797979', '#797979', '#858585', '#929292', '#999999'], ['#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#8c8c8c', '#8c8c8c', '#8c8c8c', '#858585', '#797979', '#858585', '#929292', '#999999'], ['#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#8c8c8c', '#929292', '#999999'], ['#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999', '#999999'], ['#999999', '#999999', '#999999', '#999999', '#999999']]
>>> a.setData(data)
>>> a.process()

inherits from: Graph

GraphColorGrid attributes

Attributes without Documentation: windowStep, maxWindow, minWindow

Attributes inherited from Graph: fontFamily, doneAction, title, colorBackgroundFigure, colors, tickFontSize, colorGrid, figureSize, colorBackgroundData, axisKeys, grid, titleFontSize, alpha, labelFontSize, data, axis

GraphColorGrid methods

process()
No documentation.
setColors(colors)
No documentation.
setMaxWindow(maxWindow)
No documentation.
setMinWindow(minWindow)
No documentation.
setWindowStep(windowStep)
No documentation.

Methods inherited from Graph: done(), setAxisLabel(), setAxisRange(), setData(), setDoneAction(), setFigureSize(), setTicks(), setTitle(), show(), write()

GraphHistogram

class music21.graph.GraphHistogram(*args, **keywords)

Graph the count of a single element. Data set is simply a list of x and y pairs, where there is only one of each x value, and y value is the count or magnitude of that value

>>> from music21 import *
>>> import random
>>> g = graph.GraphHistogram()
>>> data = [(x, random.choice(range(30))) for x in range(50)]
>>> g.setData(data)
>>> g.process()
_images/GraphHistogram.png

inherits from: Graph

GraphHorizontalBar

class music21.graph.GraphHorizontalBar(*args, **keywords)

Numerous horizontal bars in discrete channels, where bars can be incomplete and/or overlap. Data provided is a list of pairs, where the first value becomes the key, the second value is a list of x-start, x-length values.

>>> from music21 import *
>>> a = graph.GraphHorizontalBar(doneAction='show')
>>> data = [('Chopin', [(1810, 1849-1810)]), ('Schumanns', [(1810, 1856-1810), (1819, 1896-1819)]), ('Brahms', [(1833, 1897-1833)])]
>>> a.setData(data)
>>> a.process()
_images/GraphHorizontalBar.png

inherits from: Graph

GraphScatter

class music21.graph.GraphScatter(*args, **keywords)

Graph two parameters in a scatter plot. Data representation is a list of points of values.

>>> from music21 import *
>>> g = graph.GraphScatter()
>>> data = [(x, x*x) for x in range(50)]
>>> g.setData(data)
>>> g.process()
_images/GraphScatter.png

inherits from: Graph

GraphScatterWeighted

class music21.graph.GraphScatterWeighted(*args, **keywords)

A scatter plot where points are scaled in size to represent the number of values stored within.

>>> from music21 import *
>>> g = graph.GraphScatterWeighted()
>>> data = [(23, 15, 234), (10, 23, 12), (4, 23, 5), (15, 18, 120)]
>>> g.setData(data)
>>> g.process()
_images/GraphScatterWeighted.png

inherits from: Graph

Plot3DBars

class music21.graph.Plot3DBars(streamObj, *args, **keywords)

Base class for Stream plotting classes.

inherits from: PlotStream

Plot3DBars attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

Plot3DBars properties

Properties inherited from PlotStream: id

Plot3DBars methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotColorGrid

class music21.graph.PlotColorGrid(streamObj, AnalysisProcessor, *args, **keywords)

inherits from: PlotStream

PlotColorGrid attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotColorGrid properties

Properties inherited from PlotStream: id

PlotColorGrid methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotColorGridKrumhanslSchmuckler

class music21.graph.PlotColorGridKrumhanslSchmuckler(streamObj, *args, **keywords)

Subclass for plotting Krumhansl-Schmuckler analysis routine

inherits from: PlotColorGrid, PlotStream

PlotColorGridKrumhanslSchmuckler attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotColorGridKrumhanslSchmuckler properties

Properties inherited from PlotStream: id

PlotColorGridKrumhanslSchmuckler methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotColorGridSadoianAmbitus

class music21.graph.PlotColorGridSadoianAmbitus(streamObj, *args, **keywords)

Subclass for plotting basic pitch span over a windowed analysis

inherits from: PlotColorGrid, PlotStream

PlotColorGridSadoianAmbitus attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotColorGridSadoianAmbitus properties

Properties inherited from PlotStream: id

PlotColorGridSadoianAmbitus methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHistogram

class music21.graph.PlotHistogram(streamObj, *args, **keywords)

Base class for Stream plotting classes.

inherits from: PlotStream

PlotHistogram attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotHistogram properties

Properties inherited from PlotStream: id

PlotHistogram methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotHorizontalBar

class music21.graph.PlotHorizontalBar(streamObj, *args, **keywords)

A graph of events, sorted by pitch, over time

inherits from: PlotStream

PlotHorizontalBar attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotHorizontalBar properties

Properties inherited from PlotStream: id

PlotHorizontalBar methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatter

class music21.graph.PlotScatter(streamObj, *args, **keywords)

Base class for 2D Scatter plots.

inherits from: PlotStream

PlotScatter attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotScatter properties

Properties inherited from PlotStream: id

PlotScatter methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterPitchSpaceDynamicSymbol

class music21.graph.PlotScatterPitchSpaceDynamicSymbol(streamObj, *args, **keywords)

A graph of dynamics used by pitch space.

>>> from music21 import *
>>> s = corpus.parseWork('schumann/opus41no1', 2)
>>> p = graph.PlotScatterPitchSpaceDynamicSymbol(s)
>>> p.id
'scatter-pitchClass-dynamicSymbol'
>>> p.process()
_images/PlotScatterPitchSpaceDynamicSymbol.png

inherits from: PlotScatter, PlotStream

PlotScatterPitchSpaceDynamicSymbol attributes

Attributes without Documentation: values

Attributes inherited from PlotScatter: format

PlotScatterPitchSpaceDynamicSymbol properties

Properties inherited from PlotStream: id

PlotScatterPitchSpaceDynamicSymbol methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterWeighted

class music21.graph.PlotScatterWeighted(streamObj, *args, **keywords)

inherits from: PlotStream

PlotScatterWeighted attributes

Attributes without Documentation: format

Attributes inherited from PlotStream: values

PlotScatterWeighted properties

Properties inherited from PlotStream: id

PlotScatterWeighted methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotScatterWeightedPitchSpaceDynamicSymbol

class music21.graph.PlotScatterWeightedPitchSpaceDynamicSymbol(streamObj, *args, **keywords)

A graph of dynamics used by pitch space.

_images/PlotScatterWeightedPitchSpaceDynamicSymbol.png

inherits from: PlotScatterWeighted, PlotStream

PlotScatterWeightedPitchSpaceDynamicSymbol attributes

Attributes without Documentation: values

Attributes inherited from PlotScatterWeighted: format

PlotScatterWeightedPitchSpaceDynamicSymbol properties

Properties inherited from PlotStream: id

PlotScatterWeightedPitchSpaceDynamicSymbol methods

Methods inherited from PlotStream: process(), remapQuarterLength(), show(), ticksDynamics(), ticksOffset(), ticksPitchClass(), ticksPitchClassUsage(), ticksPitchSpaceChromatic(), ticksPitchSpaceOctave(), ticksPitchSpaceUsage(), ticksQuarterLength(), write()

PlotStream

class music21.graph.PlotStream(streamObj, flatten=True, *args, **keywords)

Approaches to plotting and graphing a stream. A base class from which Stream plotting Classes inherit.

Provide a Stream as an arguement. If flatten is True, the Stream will automatically be flattened.

PlotStream attributes

Attributes without Documentation: format, values

PlotStream properties

id
Each PlotStream has a unique id that consists of its format and a string that defines the parameters that are graphed.

PlotStream methods

process()
This will process all data, as well as call the done() method. What happens when the done() is called is determined by the the keyword argument doneAction; options are ‘show’ (display immediately), ‘write’ (write the file to a supplied file path), and None (do processing but do not write or show a graph).
remapQuarterLength(x)
Remap all quarter lengths.
show()
Call internal Graphs show() method independently of doneAction set and run with process()
ticksDynamics(minNameIndex=None, maxNameIndex=None)

Utility method to get ticks in dynamic values.

>>> from music21 import stream; s = stream.Stream()
>>> a = PlotStream(s)
>>> a.ticksDynamics()
[[0, 'pppppp'], [1, 'ppppp'], [2, 'pppp'], [3, 'ppp'], [4, 'pp'], [5, 'p'], [6, 'mp'], [7, 'mf'], [8, 'f'], [9, 'fp'], [10, 'sf'], [11, 'ff'], [12, 'fff'], [13, 'ffff'], [14, 'fffff'], [15, 'ffffff']]
>>> a.ticksDynamics(3,6)
[[3, 'ppp'], [4, 'pp'], [5, 'p'], [6, 'mp']]
ticksOffset(offsetMin=None, offsetMax=None, offsetStepSize=None, displayMeasureNumberZero=False, remap=False)

Get offset ticks. If Measures are found, they will be used to create ticks. If not, offsetStepSize will be used to create offset ticks between min and max. The remap parameter is not yet used.

>>> from music21 import corpus, stream, note
>>> s = corpus.parseWork('bach/bwv281.xml')
>>> a = PlotStream(s)
>>> a.ticksOffset() # on whole score
[[4.0, '1'], [8.0, '2'], [12.0, '3'], [16.0, '4'], [20.0, '5'], [24.0, '6'], [28.0, '7'], [32.0, '8']]
>>> a = PlotStream(s[0]) # on a Part
>>> a.ticksOffset() # on whole score
[[4.0, '1'], [8.0, '2'], [12.0, '3'], [16.0, '4'], [20.0, '5'], [24.0, '6'], [28.0, '7'], [32.0, '8']]
>>> a.ticksOffset(8, 12, 2)
[[8.0, '2'], [12.0, '3']]
>>> a = PlotStream(s[0].flat) # on a Flat collection
>>> a.ticksOffset(8, 12, 2)
[[8.0, '2'], [12.0, '3']]
>>> n = note.Note('a') # on a raw collection of notes with no measures
>>> s = stream.Stream()
>>> s.repeatAppend(n, 10)
>>> a = PlotStream(s) # on a Part
>>> a.ticksOffset() # on whole score
[[0, '0'], [10, '10']]
ticksPitchClass(pcMin=0, pcMax=11)

Utility method to get ticks in pitch classes

>>> from music21 import corpus
>>> s = corpus.parseWork('bach/bwv324.xml')
>>> a = PlotStream(s)
>>> a.ticksPitchClass()
[[0, 'C'], [1, 'C#'], [2, 'D'], [3, 'D#'], [4, 'E'], [5, 'F'], [6, 'F#'], [7, 'G'], [8, 'G#'], [9, 'A'], [10, 'A#'], [11, 'B']]
ticksPitchClassUsage(pcMin=0, pcMax=11, showEnharmonic=True, blankLabelUnused=True, hideUnused=False)

Get ticks and labels for pitch classes based on usage. That is, show the most commonly used enharmonic first.

>>> from music21 import corpus
>>> s = corpus.parseWork('bach/bwv324.xml')
>>> a = PlotStream(s)
>>> a.ticksPitchClassUsage(hideUnused=True)
[[0, u'C'], [2, u'D'], [3, u'D#'], [4, u'E'], [6, u'F#'], [7, u'G'], [9, u'A'], [11, u'B']]
>>> s = corpus.parseWork('bach/bwv281.xml')
>>> a = PlotStream(s)
>>> a.ticksPitchClassUsage(showEnharmonic=True, hideUnused=True)
[[0, u'C'], [2, u'D'], [3, u'Eb'], [4, u'E'], [5, u'F'], [7, u'G'], [9, u'A'], [10, u'Bb'], [11, u'B']]
>>> a.ticksPitchClassUsage(showEnharmonic=True, blankLabelUnused=False)
[[0, u'C'], [1, 'C#'], [2, u'D'], [3, u'Eb'], [4, u'E'], [5, u'F'], [6, 'F#'], [7, u'G'], [8, 'G#'], [9, u'A'], [10, u'Bb'], [11, u'B']]
>>> s = corpus.parseWork('schumann/opus41no1/movement2.xml')
>>> a = PlotStream(s)
>>> a.ticksPitchClassUsage(showEnharmonic=True)
[[0, u'C'], [1, u'Db/C#'], [2, u'D'], [3, u'Eb/D#'], [4, u'E'], [5, u'F'], [6, u'F#'], [7, u'G'], [8, u'Ab/G#'], [9, u'A'], [10, u'Bb'], [11, u'B']]
ticksPitchSpaceChromatic(pitchMin=36, pitchMax=100)

Utility method to get ticks in pitch space values.

>>> from music21 import stream; s = stream.Stream()
>>> a = PlotStream(s)
>>> a.ticksPitchSpaceChromatic(60,72)
[[60, 'C4'], [61, 'C#4'], [62, 'D4'], [63, 'D#4'], [64, 'E4'], [65, 'F4'], [66, 'F#4'], [67, 'G4'], [68, 'G#4'], [69, 'A4'], [70, 'A#4'], [71, 'B4'], [72, 'C5']]
ticksPitchSpaceOctave(pitchMin=36, pitchMax=100)

Utility method to get ticks in pitch space only for every octave.

>>> from music21 import stream; s = stream.Stream()
>>> a = PlotStream(s)
>>> a.ticksPitchSpaceOctave()
[[36, 'C2'], [48, 'C3'], [60, 'C4'], [72, 'C5'], [84, 'C6'], [96, 'C7']]
ticksPitchSpaceUsage(pcMin=36, pcMax=72, showEnharmonic=False, blankLabelUnused=True, hideUnused=False)

Get ticks and labels for pitch space based on usage. That is, show the most commonly used enharmonic first.

>>> from music21 import corpus
>>> s = corpus.parseWork('bach/bwv324.xml')
>>> a = PlotStream(s[0])
>>> a.ticksPitchSpaceUsage(hideUnused=True)
[[64, u'E4'], [66, u'F#4'], [67, u'G4'], [69, u'A4'], [71, u'B4'], [72, u'C5']]
>>> s = corpus.parseWork('schumann/opus41no1/movement2.xml')
>>> a = PlotStream(s)
>>> a.ticksPitchSpaceUsage(showEnharmonic=True, hideUnused=True)
[[36, u'C2'], [38, u'D2'], [40, u'E2'], [41, u'F2'], [43, u'G2'], [44, u'Ab2'], [45, u'A2'], [47, u'B2'], [48, u'C3'], [50, u'D3'], [51, u'Eb3/D#3'], [52, u'E3'], [53, u'F3'], [54, u'F#3'], [55, u'G3'], [56, u'Ab3/G#3'], [57, u'A3'], [58, u'Bb3'], [59, u'B3'], [60, u'C4'], [61, u'Db4/C#4'], [62, u'D4'], [63, u'Eb4/D#4'], [64, u'E4'], [65, u'F4'], [66, u'F#4'], [67, u'G4'], [68, u'Ab4/G#4'], [69, u'A4'], [70, u'Bb4'], [71, u'B4'], [72, u'C5']]
ticksQuarterLength(min=0.25, max=4, remap=True)

Get ticks for quarterLength. If remap is True, the remapQuarterLength() function will be used to scale displayed quarter lengths by log base 2.

>>> from music21 import stream; s = stream.Stream()
>>> a = PlotStream(s)
write(fp=None)
Call internal Graphs write() method independently of doneAction set and run with process()