In [1]:
import numpy as np
import pandas as pd
from dataframe_plotter import dataframe_plotter
%matplotlib inline
In [2]:
index = pd.date_range('2016-01-01', '2017-01-01', freq='H')
df = pd.DataFrame(np.arange(len(index)), index=index, columns=['linear'])
x = np.arange(len(df))
df['sin_year'] = np.sin(1 * 2 * np.pi * x / len(df))
df['sin_month'] = np.sin(12 * 2 * np.pi * x / len(df))
df['sin_day'] = np.sin(365 * 2 * np.pi * x / len(df))
df['cos_year'] = np.cos(1 * 2 * np.pi * x / len(df))
df['cos_month'] = np.cos(12 * 2 * np.pi * x / len(df))
df['cos_day'] = np.cos(365 * 2 * np.pi * x / len(df))
df['10sin_month'] = 10 * df['sin_month'] + df['sin_day']
df['10cos_month'] = 10 * df['cos_month'] + df['cos_day']
df.head()
Out[2]:
In [3]:
dataframe_plotter(df, title='Single Plot', ylabel='All columns', xlabel='Datetime')
In [4]:
dataframe_plotter(df, subplots=True, title=['First plot', 'Seconds plot'], xlabel='Datetime',
x_label_rotation=30)
In [5]:
subplots = ['linear', ['sin_month', 'cos_month']]
title = ['Linear', 'Monthly sin and cos']
dataframe_plotter(df, subplots=subplots, title=title, xlabel='Datetime', dots=False)
In [6]:
subplots = ['linear', 'sin_month', 'cos_month']
ylabel = ['lin', 'sin', 'cos']
secondary_y = ['', ['10sin_month', '10cos_month']]
secondary_y_label = ['', '10*sin and 10*cos with noise']
dataframe_plotter(df, subplots=subplots, ylabel=ylabel,
secondary_y=secondary_y, secondary_ylabel=secondary_y_label,
dots=False, linewidth=2, height_per_plot=4)
In [7]:
dataframe_plotter(df, plot_type='average', title='Plot average value at time of day',
subplots=[['sin_day', 'cos_day']], xlabel='hour in day')