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

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

In [3]:
vis.plot_line(x, y, title='Stack Plots')
vis.plot_bar(x, y, figsize='na', color=vis.COLORS['teal']) # stack plots by setting figsize to arbitrary string


Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc6697d8e48>
/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[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc6697d8e48>

In [4]:
ax = vis.plot_line(x, y, rows=2, pos=1, title='Share X')
vis.plot_line(x, y2, rows=2, pos=2, sharex=ax) # two subplots and sharex


Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc6697d8dd8>

In [5]:
vis_dict = dict(rows=2, cols=2, ylabel='y', xlabel='x') # shared keywords

ax = vis.plot_line(x, y, title='Subplot 1', pos=1, **vis_dict)
ax2 = vis.plot_line(x, y, title='Subplot 2', pos=2, **vis_dict)
ax3 = vis.plot_line(x, y2, title='Subplot 3', pos=3, **vis_dict)
ax4 = vis.plot_line(x, y2, title='Subplot 4', pos=4, **vis_dict) # four subplots and share y
vis.utils(tight_layout=True) # when things stack on each other



In [6]:
ax = vis.plot_line(x, y, title='Twin X')
vis.plot_line(x, y2, twinx=ax, color=vis.COLORS['teal'], aligned=True) # two y-axes


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc6647d8080>
<matplotlib.figure.Figure at 0x7fc667d76fd0>

In [7]:
vis.set_figsize(figsize=(12, 4))
subplot_tup = (3, 16) # 5 rows 16 cols
ax1 = plt.subplot2grid(subplot_tup, (0, 0), colspan=16) # take the entire first row for line plot
ax2 = plt.subplot2grid(subplot_tup, (1, 0), colspan=15, rowspan=2) # take the 2 rows and 15 cols for scatter plot
ax3 = plt.subplot2grid(subplot_tup, (1, 15), colspan=1, rowspan=2) # take the 2 rows and 1 col for colorbar
plt.subplots_adjust(bottom=0, top=3)

ax = vis.plot_line(x, y, ax=ax1, xlabel='x', ylabel='line')
ax2, im = vis.plot_scatter(x, y, ax=ax2, c=y, cbar=False, xlabel='x', ylabel='scatter', returnplot=True) # returnplot for im
vis.set_cbar(ax2, im, cax=ax3, orientation='vertical', tick_size=8)
plt.close()


Out[7]:
<matplotlib.figure.Figure at 0x7fc669761cc0>
Out[7]:
<matplotlib.colorbar.Colorbar at 0x7fc667870160>
<matplotlib.figure.Figure at 0x7fc6673619e8>

In [ ]: