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]:
Out[3]:
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]:
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]:
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]:
Out[7]:
In [ ]: