<commit_before>#!/usr/bin/env python
#  -*- coding: utf-8 -*-
from __future__ import print_function, division

import nix
import numpy as np
import scipy.signal as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
from IPython import embed

class Plotter(object):
    def __init__(self, try_ggplot_style=True):
        self._post_plot_hook = None

        if try_ggplot_style:
            self._setup_ggplot()

        self.fig = plt.figure(facecolor='white')
        plt.hold('on')
        self._n_plots = 0
        self._x_range = None
        self.axis = None

    def _setup_ggplot(self):
        try:
            from ggplot import theme_bw
            t = theme_bw()
            for k, v in t.get_rcParams().iteritems():
                mpl.rcParams[k] = v

            def plot_post_hook():
                for ax in self.figure.axes:
                    t.post_plot_callback(ax)
            self._post_plot_hook = plot_post_hook
        except ImportError:
            pass
        except AttributeError:
            pass

    @property<commit_msg>add argument to plotting._init_ to allow passing an external figure<commit_after>#!/usr/bin/env python
#  -*- coding: utf-8 -*-
from __future__ import print_function, division

import nix
import numpy as np
import scipy.signal as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
from IPython import embed

class Plotter(object):
    def __init__(self, figure=None, try_ggplot_style=True):
        self._post_plot_hook = None
        
        if try_ggplot_style:
            self._setup_ggplot()
        if figure is None:
            self.fig = plt.figure(facecolor='white')
            plt.hold('on')
        else:
            self.fig = figure
        self._n_plots = 0
        self._x_range = None
        self.axis = None

    def _setup_ggplot(self):
        try:
            from ggplot import theme_bw
            t = theme_bw()
            for k, v in t.get_rcParams().iteritems():
                mpl.rcParams[k] = v

            def plot_post_hook():
                for ax in self.figure.axes:
                    t.post_plot_callback(ax)
            self._post_plot_hook = plot_post_hook
        except ImportError:
            pass
        except AttributeError:
            pass

    @property
{'fraction_non_alphanumeric': 0.07833698030634573, 'fraction_numerical': 0.00175054704595186, 'mean_word_length': 1.8790931989924433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6392006', 'n_tokens_mistral': 690, 'n_tokens_neox': 670, 'n_words': 180}