In [1]:
from ahh import vis, exp
import matplotlib.pyplot as plt # to show equivalent

In [2]:
x = exp.arr_1d() * 2
y = exp.arr_1d(y=True) # create random data

print(x)
print(y) # reference


[ 2  4  6  8 10 12 14 16 18 20 22 24 26 28 30]
[  1.           1.36948443   2.17767582   2.78028097   4.04092175
   5.25037077   4.82017551   2.26645897   8.83665651   4.80242618
   8.80940153   8.64045752   2.52545074   4.19633841  13.83046537]

In [3]:
plt.plot(y) # equivalent to one directly below


Out[3]:
[<matplotlib.lines.Line2D at 0x7ff4fce32978>]

In [4]:
ax = vis.plot_line(y) # simplest usage, just input y



In [5]:
plt.scatter(x, y) # equivalent to one directly below
plt.xlabel('x')
plt.ylabel('y')
plt.title('Example')
plt.xlim(-1, 31)
plt.ylim(0, 14)


Out[5]:
<matplotlib.collections.PathCollection at 0x7ff4fbcc9f28>
Out[5]:
Text(0.5,0,'x')
Out[5]:
Text(0,0.5,'y')
Out[5]:
Text(0.5,1,'Example')
Out[5]:
(-1, 31)
Out[5]:
(0, 14)

In [6]:
vis.plot_scatter(x, y, xlabel='x', ylabel='y', title='Example', xlim=(-1, 31), ylim=(0, 14)) # input x, add labels and limits


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff4fa2ff9b0>

In [7]:
x = exp.arr_dt().to_pydatetime() # random datetimes
y2 = exp.arr_1d(y=True)
print(x, y2)


[datetime.datetime(2016, 2, 28, 0, 0) datetime.datetime(2016, 2, 29, 0, 0)
 datetime.datetime(2016, 3, 1, 0, 0) datetime.datetime(2016, 3, 2, 0, 0)
 datetime.datetime(2016, 3, 3, 0, 0) datetime.datetime(2016, 3, 4, 0, 0)
 datetime.datetime(2016, 3, 5, 0, 0) datetime.datetime(2016, 3, 6, 0, 0)
 datetime.datetime(2016, 3, 7, 0, 0) datetime.datetime(2016, 3, 8, 0, 0)
 datetime.datetime(2016, 3, 9, 0, 0) datetime.datetime(2016, 3, 10, 0, 0)
 datetime.datetime(2016, 3, 11, 0, 0) datetime.datetime(2016, 3, 12, 0, 0)
 datetime.datetime(2016, 3, 13, 0, 0)] [  1.           1.83682385   2.86190443   3.66388531   3.97931369
   5.75346129   2.86574081   6.54484814   5.1596418    3.60684509
  10.78625767   3.7442309    7.73321874   2.76825851   2.82293006]

In [8]:
plt.plot(x, y, label='Blue', linestyle='--')
plt.legend() # equivalent to below


Out[8]:
[<matplotlib.lines.Line2D at 0x7ff4fba46400>]
Out[8]:
<matplotlib.legend.Legend at 0x7ff4fa2c9a90>

In [9]:
vis.plot_line(x, y, label='Red', linestyle='--') # label and legend automatically shows


Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff4fba765c0>

In [17]:
x = exp.arr_1d()
y2 = exp.arr_1d(y=True)

vis_dict = dict(rows=2, # specify number of subplots
                sidebar_count=2, # specify number of side by side bars
                xlabel='x', title='Vis Demonstration', suptitle=True,
                title_pad=0.9, figsize='na')

vis.set_figsize(15, 8) # set figure size
vis.plot_bar(x, y, label='Red Bars', ylabel='Values', **vis_dict)
vis.plot_bar(x, y2, label='Blue Bars', sidebar_pos=2, color='blue', **vis_dict)

vis.plot_hist(['Chicken'] * 5 + ['Egg'] * 2 + ['Spam'], # random data
              rows=2, pos=2, ptype='bar',
              ylabel='Count', color='orange', # labels and color
              cumsum=True) # get cumulative count


Out[17]:
<matplotlib.figure.Figure at 0x7ff4fadca1d0>
Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff4fadca8d0>
/home/solactus/anaconda3/lib/python3.5/site-packages/matplotlib/cbook/deprecation.py:106: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
  warnings.warn(message, mplDeprecation, stacklevel=1)
Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff4fadca8d0>

In [ ]: