In [1]:
%matplotlib inline
from ahh import ext, vis, sci
import numpy as np
import pandas as pd
import datetime
colors = vis.COLORS
In [2]:
x = np.arange(-13, 13, 2)
vis.utils(figsize=(20, 10))
for i, (name, color) in enumerate(sorted(colors.items())):
y = x * -i
ax = vis.plot_line(x, y, color=color, linewidth=2, label=name,
title='omnitakes', xlabel='x', ylabel='y', figsize='na')
vis.set_legend(ax, ncol=2)
Out[2]:
Out[2]:
In [3]:
length = 31
x = np.arange(length)
y = np.square(x)
ax = vis.plot_line(x, y, figsize='wide')
vis.set_labels(ax, 'x', 'y', 'Grids, Axes, and Borders Demonstration')
vis.set_major_grid(ax, linestyle='--')
vis.set_borders(ax, all_=False)
vis.set_major_ticks(ax, left=False, bottom=False)
Out[3]:
Out[3]:
Out[3]:
Out[3]:
In [4]:
length = 26
x = np.arange(length)
y = np.sin(x)
ax = vis.plot_scatter(x, y, color=colors['orange'], figsize=(10, 6),
xlabel='x', ylabel='y', yinvert=True,
title='Scatter, Yinvert, Scale Demonstration')
vis.set_major_tick_labels(ax)
Out[4]:
In [5]:
start = datetime.datetime(2016, 1, 1)
end = datetime.datetime(2016, 2, 28)
dt_range = pd.date_range(start, end)
y = np.sqrt(range(len(dt_range)))
ax = vis.plot_line(dt_range, y, color=colors['green'], figsize=(15, 10))
vis.set_labels(ax, title='Datetime Demonstration', xlabel='days', ylabel='y', title_pad=1.1)
formatted = sci.get_stats(y, return_str='vertical')
vis.set_figtext(ax, text=formatted, loc='center right', pad=0.05)
Out[5]:
In [6]:
x = np.arange(0, 10, 2)
y = [2, 4, 6, 8, 10]
z = [1, 3, 5, 7, 9]
vis.utils(figsize=(45, 15))
ax3 = vis.plot_line(x, y, rows=1, cols=3, figsize='n', pos=3, title='Position 3', xlabel='Large xlabel', ylabel='left ylabel')
ax3_twin = vis.plot_line(x, z, rows=1, cols=3, pos=3,
title='inheriting title', xlabel='inherited xlabel',
ylabel='Large ylabel', twinx=ax3, color='blue')
vis.set_major_grid(ax3, linestyle='--')
ax4 = vis.plot_scatter(x, y, rows=2, cols=3, figsize='n', pos=4, title='Position 4',
xlabel='some xlabel', ylabel='left ylabel',
color=colors['orange'])
ax5 = vis.plot_bar(x, z, rows=2, cols=3, figsize='n', pos=5, title='Position 5', xlabel='Shared xlabel', hist=True, sharey=ax4)
vis.set_axes(ax5, xlim=(0, 6))
ax1 = vis.plot_scatter(x, y, rows=2, cols=3, figsize='n', pos=1, title='Position 1',
xlabel='Can still show xlabel', ylabel='Shared ylabel',
sharex=ax4)
ax1_twin = vis.plot_bar(x, z, rows=2, cols=3, figsize='n', pos=1, twinx=ax1,
color=colors['blue'],
ylabel='Twin ylabel',
sharex=ax4)
vis.set_axes(ax1, xlim=(-2, 10))
ax2 = vis.plot_line(x, y, rows=2, cols=3, figsize='n', pos=2, title='Position 2',
ylabel='Can still show ylabel',
sharey=ax1, sharex=ax5, tight_layout='on')
Out[6]:
Out[6]:
Out[6]:
Out[6]:
In [7]:
y = ['orange', 'pear', 'apple', 'pear', 'apple', 'orange', 'apple'] * 10 + ['orange'] + ['banana'] * 5
ax = vis.plot_bar(x='auto', y=y, hist=True, title='Fruit Histogram', width=0.8, figsize=(10, 5),
xlabel='Fruit', ylabel='Count', color=colors['orange'])
In [8]:
labels =['A','B','A','C','A','A']
vis.plot_bar(x='text', y=labels, hist=True, align='center', title='Text Histogram', figsize=(4, 2), color=colors['purple'])
Out[8]:
In [9]:
from ahh import ext, vis, sci
import numpy as np
import pandas as pd
import datetime
colors = vis.COLORS
%matplotlib inline
scores = [99., 96., 94., 92., 86., 84., 82, 81, 80, 88., 94., 95., 90, 90, 90, 85, 83, 82, 81, 85, 75, 74, 54, 100]
ax = vis.plot_bar(y=scores, title='Number Hist', figsize=(15, 10),
ylabel='Count', xlabel='Score', hist=True, align='edge', width=5, xlim=(50, 100), stats='top left')
In [ ]:
In [ ]:
In [ ]:
In [ ]: