Testing Plotting w/o Music21¶
These are tests to see what difference importing music21 does to the current Jupyter/Matplotlib/numpy installation
import matplotlib.pyplot as plt
plt.plot(range(10))
[<matplotlib.lines.Line2D at 0x114572910>]
a = plt.plot(range(10))
a
[<matplotlib.lines.Line2D at 0x1146be810>]
from matplotlib.figure import Figure
fig = Figure()
fig
<Figure size 640x480 with 0 Axes>
ax = fig.add_subplot()
fig # note that this would not show anything unless we had already done plt.plot()
repr(fig)
'<Figure size 640x480 with 1 Axes>'
from IPython import get_ipython # as shell
shell = get_ipython()
formatter = shell.display_formatter
formatter
<IPython.core.formatters.DisplayFormatter at 0x10f857090>
png_formatter = formatter.formatters['image/png']
png_formatter
<IPython.core.formatters.PNGFormatter at 0x11459b850>
dir(png_formatter)
['__annotations__',
'__call__',
'__class__',
'__contains__',
'__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__',
'__str__',
'__subclasshook__',
'__weakref__',
'_add_notifiers',
'_all_trait_default_generators',
'_check_return',
'_config_changed',
'_cross_validation_lock',
'_defining_class',
'_descriptors',
'_find_my_config',
'_get_trait_default_generator',
'_in_deferred_types',
'_instance_inits',
'_load_config',
'_notify_observers',
'_notify_trait',
'_register_validator',
'_remove_notifiers',
'_return_type',
'_static_immutable_initial_values',
'_trait_default_generators',
'_trait_notifiers',
'_trait_validators',
'_trait_values',
'_traits',
'add_traits',
'class_config_rst_doc',
'class_config_section',
'class_get_help',
'class_get_trait_help',
'class_own_trait_events',
'class_own_traits',
'class_print_help',
'class_trait_names',
'class_traits',
'config',
'cross_validation_lock',
'deferred_printers',
'enabled',
'for_type',
'for_type_by_name',
'format_type',
'has_trait',
'hold_trait_notifications',
'lookup',
'lookup_by_type',
'notify_change',
'observe',
'on_trait_change',
'parent',
'pop',
'print_method',
'section_names',
'set_trait',
'setup_instance',
'singleton_printers',
'trait_defaults',
'trait_events',
'trait_has_value',
'trait_metadata',
'trait_names',
'trait_values',
'traits',
'type_printers',
'unobserve',
'unobserve_all',
'update_config']
png_formatter.type_printers
{matplotlib.figure.Figure: functools.partial(<function print_figure at 0x10f432480>, fmt='png', base64=True, bbox_inches='tight')}
fig.canvas
<matplotlib.backend_bases.FigureCanvasBase at 0x1146f6150>
fig.canvas.print_figure
<bound method FigureCanvasBase.print_figure of <matplotlib.backend_bases.FigureCanvasBase object at 0x1146f6150>>
# x = fig.canvas.print_figure('asdf') # will write out a file called asdf.png
# x is None