HOME/Articles/

matplotlib example output to clipboard (snippet)

Article Outline

Python matplotlib example 'output to clipboard'

Functions in program:

  • def clip(line):

python output to clipboard

Python matplotlib example: output to clipboard

## Send content to clipboard in ipython
from IPython.core.magic import register_line_magic
@register_line_magic
def clip(line):
    global_dict = globals()
    if not line in global_dict:
        return
    value = global_dict[line]
    import os    
    os.system("echo '%s' | pbcopy" % str(value))
    # os.system("echo '%s' | clip" % str(value)) # for windows
del clip