Python pandas.plotting() Examples

The following are 15 code examples of pandas.plotting(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas , or try the search function .
Example #1
Source File: plotting.py    From modin with Apache License 2.0 6 votes vote down vote up
def __getattribute__(self, item):
        """This method will override the parameters passed and convert any Modin
            DataFrames to pandas so that they can be plotted normally
        """
        if hasattr(pdplot, item):
            func = getattr(pdplot, item)
            if callable(func):

                def wrap_func(*args, **kwargs):
                    """Convert Modin DataFrames to pandas then call the function"""
                    args = tuple(
                        arg if not isinstance(arg, DataFrame) else to_pandas(arg)
                        for arg in args
                    )
                    kwargs = {
                        kwd: val if not isinstance(val, DataFrame) else to_pandas(val)
                        for kwd, val in kwargs.items()
                    }
                    return func(*args, **kwargs)

                return wrap_func
            else:
                return func
        else:
            return object.__getattribute__(self, item) 
Example #2
Source File: common.py    From recruit with Apache License 2.0 5 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
        self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0()
        self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()
        self.mpl_ge_2_2_2 = plotting._compat._mpl_ge_2_2_2()
        self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0()

        self.bp_n_objects = 7
        self.polycollection_factor = 2
        self.default_figsize = (6.4, 4.8)
        self.default_tick_position = 'left'

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)}) 
Example #3
Source File: common.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def _ok_for_gaussian_kde(kind):
    if kind in ['kde', 'density']:
        try:
            from scipy.stats import gaussian_kde  # noqa
        except ImportError:
            return False

    return plotting._compat._mpl_ge_1_5_0() 
Example #4
Source File: plotting.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def outer(t=t):

        def wrapper(*args, **kwargs):
            warnings.warn("'pandas.tools.plotting.{t}' is deprecated, "
                          "import 'pandas.plotting.{t}' instead.".format(t=t),
                          FutureWarning, stacklevel=2)
            return getattr(_plotting, t)(*args, **kwargs)
        return wrapper 
Example #5
Source File: common.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
        self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0()
        self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()
        self.mpl_ge_2_2_2 = plotting._compat._mpl_ge_2_2_2()
        self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0()

        self.bp_n_objects = 7
        self.polycollection_factor = 2
        self.default_figsize = (6.4, 4.8)
        self.default_tick_position = 'left'

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)}) 
Example #6
Source File: plotting.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def outer(t=t):

        def wrapper(*args, **kwargs):
            warnings.warn("'pandas.tools.plotting.{t}' is deprecated, "
                          "import 'pandas.plotting.{t}' instead.".format(t=t),
                          FutureWarning, stacklevel=2)
            return getattr(_plotting, t)(*args, **kwargs)
        return wrapper 
Example #7
Source File: utils.py    From fractional-differentiation-time-series with MIT License 5 votes vote down vote up
def plot_multi(data, cols=None, spacing=.1, **kwargs):
    from pandas import plotting

    # Get default color style from pandas - can be changed to any other color list
    if cols is None: cols = data.columns
    if len(cols) == 0: return
    colors = getattr(getattr(plotting, '_style'), '_get_standard_colors')(num_colors=len(cols))

    # First axis
    ax = data.loc[:, cols[0]].plot(label=cols[0], color=colors[0], **kwargs)
    ax.set_ylabel(ylabel=cols[0])
    lines, labels = ax.get_legend_handles_labels()

    for n in range(1, len(cols)):
        # Multiple y-axes
        ax_new = ax.twinx()
        ax_new.spines['right'].set_position(('axes', 1 + spacing * (n - 1)))
        data.loc[:, cols[n]].plot(ax=ax_new, label=cols[n], color=colors[n % len(colors)])
        ax_new.set_ylabel(ylabel=cols[n])

        # Proper legend position
        line, label = ax_new.get_legend_handles_labels()
        lines += line
        labels += label

    ax.legend(lines, labels, loc=0)
    return ax 
Example #8
Source File: common.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def _ok_for_gaussian_kde(kind):
    if kind in ['kde', 'density']:
        try:
            from scipy.stats import gaussian_kde  # noqa
        except ImportError:
            return False

    return plotting._compat._mpl_ge_1_5_0() 
Example #9
Source File: plotting.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def outer(t=t):

        def wrapper(*args, **kwargs):
            warnings.warn("'pandas.tools.plotting.{t}' is deprecated, "
                          "import 'pandas.plotting.{t}' instead.".format(t=t),
                          FutureWarning, stacklevel=2)
            return getattr(_plotting, t)(*args, **kwargs)
        return wrapper 
Example #10
Source File: plotting.py    From modin with Apache License 2.0 5 votes vote down vote up
def __dir__(self):
        """This allows tab completion of plotting library"""
        return dir(pdplot) 
Example #11
Source File: common.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
        self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0()
        self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()
        self.mpl_ge_2_2_2 = plotting._compat._mpl_ge_2_2_2()
        self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0()

        self.bp_n_objects = 7
        self.polycollection_factor = 2
        self.default_figsize = (6.4, 4.8)
        self.default_tick_position = 'left'

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)}) 
Example #12
Source File: common.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def _ok_for_gaussian_kde(kind):
    if kind in ['kde', 'density']:
        try:
            from scipy.stats import gaussian_kde  # noqa
        except ImportError:
            return False

    return plotting._compat._mpl_ge_1_5_0() 
Example #13
Source File: common.py    From vnpy_crypto with MIT License 4 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_le_1_2_1 = plotting._compat._mpl_le_1_2_1()
        self.mpl_ge_1_3_1 = plotting._compat._mpl_ge_1_3_1()
        self.mpl_ge_1_4_0 = plotting._compat._mpl_ge_1_4_0()
        self.mpl_ge_1_5_0 = plotting._compat._mpl_ge_1_5_0()
        self.mpl_ge_2_0_0 = plotting._compat._mpl_ge_2_0_0()
        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
        self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()

        if self.mpl_ge_1_4_0:
            self.bp_n_objects = 7
        else:
            self.bp_n_objects = 8
        if self.mpl_ge_1_5_0:
            # 1.5 added PolyCollections to legend handler
            # so we have twice as many items.
            self.polycollection_factor = 2
        else:
            self.polycollection_factor = 1

        if self.mpl_ge_2_0_0:
            self.default_figsize = (6.4, 4.8)
        else:
            self.default_figsize = (8.0, 6.0)
        self.default_tick_position = 'left' if self.mpl_ge_2_0_0 else 'default'

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)}) 
Example #14
Source File: common.py    From elasticintel with GNU General Public License v3.0 4 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_le_1_2_1 = plotting._compat._mpl_le_1_2_1()
        self.mpl_ge_1_3_1 = plotting._compat._mpl_ge_1_3_1()
        self.mpl_ge_1_4_0 = plotting._compat._mpl_ge_1_4_0()
        self.mpl_ge_1_5_0 = plotting._compat._mpl_ge_1_5_0()
        self.mpl_ge_2_0_0 = plotting._compat._mpl_ge_2_0_0()
        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()

        if self.mpl_ge_1_4_0:
            self.bp_n_objects = 7
        else:
            self.bp_n_objects = 8
        if self.mpl_ge_1_5_0:
            # 1.5 added PolyCollections to legend handler
            # so we have twice as many items.
            self.polycollection_factor = 2
        else:
            self.polycollection_factor = 1

        if self.mpl_ge_2_0_0:
            self.default_figsize = (6.4, 4.8)
        else:
            self.default_figsize = (8.0, 6.0)
        self.default_tick_position = 'left' if self.mpl_ge_2_0_0 else 'default'
        # common test data
        from pandas import read_csv
        base = os.path.join(os.path.dirname(curpath()), os.pardir)
        path = os.path.join(base, 'tests', 'data', 'iris.csv')
        self.iris = read_csv(path)

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)}) 
Example #15
Source File: common.py    From twitter-stock-recommendation with MIT License 4 votes vote down vote up
def setup_method(self, method):

        import matplotlib as mpl
        mpl.rcdefaults()

        self.mpl_le_1_2_1 = plotting._compat._mpl_le_1_2_1()
        self.mpl_ge_1_3_1 = plotting._compat._mpl_ge_1_3_1()
        self.mpl_ge_1_4_0 = plotting._compat._mpl_ge_1_4_0()
        self.mpl_ge_1_5_0 = plotting._compat._mpl_ge_1_5_0()
        self.mpl_ge_2_0_0 = plotting._compat._mpl_ge_2_0_0()
        self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
        self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()

        if self.mpl_ge_1_4_0:
            self.bp_n_objects = 7
        else:
            self.bp_n_objects = 8
        if self.mpl_ge_1_5_0:
            # 1.5 added PolyCollections to legend handler
            # so we have twice as many items.
            self.polycollection_factor = 2
        else:
            self.polycollection_factor = 1

        if self.mpl_ge_2_0_0:
            self.default_figsize = (6.4, 4.8)
        else:
            self.default_figsize = (8.0, 6.0)
        self.default_tick_position = 'left' if self.mpl_ge_2_0_0 else 'default'

        n = 100
        with tm.RNGContext(42):
            gender = np.random.choice(['Male', 'Female'], size=n)
            classroom = np.random.choice(['A', 'B', 'C'], size=n)

            self.hist_df = DataFrame({'gender': gender,
                                      'classroom': classroom,
                                      'height': random.normal(66, 4, size=n),
                                      'weight': random.normal(161, 32, size=n),
                                      'category': random.randint(4, size=n)})

        self.tdf = tm.makeTimeDataFrame()
        self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
                                    "B": np.random.uniform(size=20),
                                    "C": np.arange(20) + np.random.uniform(
                                        size=20)})