Testing Plotting with Music21¶
Music21
used to manipulate the environment somewhat when loading
matplotlib in Jupyter. This seems to no longer be needed after:
https://github.com/ipython/ipython/issues/12190
But some issues still arise with double plotting of graphs and returning Axes, so this file helps test them.
from music21 import corpus
corpus.parse('bwv66.6').plot()

x = corpus.parse('bwv66.6').plot()

x is None
True
corpus.parse('bwv66.6').plot(returnInNotebook=True)
<music21.graph.plot.HorizontalBarPitchSpaceOffset for <music21.stream.Score bach/bwv66.6.mxl>>

out = corpus.parse('bwv66.6').plot(returnInNotebook=True)

out
<music21.graph.plot.HorizontalBarPitchSpaceOffset for <music21.stream.Score bach/bwv66.6.mxl>>
dir(out)
['_DOC_ATTR',
'_DOC_ORDER',
'__annotations__',
'__class__',
'__del__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getstate__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setstate__',
'__sizeof__',
'__slots__',
'__str__',
'__subclasshook__',
'__weakref__',
'_classSetCacheDict',
'_classTupleCacheDict',
'_dataColorIndex',
'_doneAction',
'_partsToColor',
'_reprInternal',
'allAxes',
'alpha',
'applyFormatting',
'applyFormattingToOneAxis',
'applyGrid',
'assignColorsToParts',
'axesClasses',
'axis',
'axisKeys',
'axisRangeHasBeenSet',
'axisX',
'axisY',
'barHeight',
'barSpace',
'callDoneAction',
'classFilterList',
'classSet',
'classes',
'colorBackgroundData',
'colorBackgroundFigure',
'colorByPart',
'colorGrid',
'colors',
'data',
'doneAction',
'dpi',
'extractChordDataMultiAxis',
'extractChordDataOneAxis',
'extractData',
'figure',
'figureSize',
'figureSizeDefault',
'fillValueLists',
'fontFamily',
'graphType',
'grid',
'hideAxisSpines',
'hideLeftBottomSpines',
'hideXGrid',
'hideYGrid',
'id',
'isClassOrSubclass',
'keywordConfigurables',
'labelFontSize',
'margin',
'marker',
'markersize',
'matchPitchCountForChords',
'nextColor',
'plt',
'postProcessData',
'postProcessElement',
'process',
'processOneElement',
'recurse',
'renderSubplot',
'run',
'savedKeywords',
'setAxisKeywords',
'setAxisLabel',
'setAxisRange',
'setIntegerTicksFromData',
'setTicks',
'show',
'streamObj',
'subplot',
'tickColors',
'tickFontSize',
'title',
'titleFontSize',
'write',
'xTickLabelHorizontalAlignment',
'xTickLabelRotation',
'xTickLabelVerticalAlignment']
out.streamObj
<music21.stream.Score bach/bwv66.6.mxl>
out.streamObj.metadata.corpusFilePath
'bach/bwv66.6.mxl'