'Output pgf commands for drawing the figure so it can be included and
rendered in latex documents.'

def print_pgf(self, fname_or_fh, *args, **kwargs):

    if kwargs.get(u'dryrun', False):
        self._print_pgf_to_fh(None, *args, **kwargs)
        return
    if isinstance(fname_or_fh, six.string_types):
        with codecs.open(fname_or_fh, u'w', encoding=u'utf-8') as fh:
            self._print_pgf_to_fh(fh, *args, **kwargs)
    elif is_writable_file_like(fname_or_fh):
        fh = codecs.getwriter(u'utf-8')(fname_or_fh)
        self._print_pgf_to_fh(fh, *args, **kwargs)
    else:
        raise ValueError(u'filename    must    be    a    path')
