def plot_bars(bar_list, tick_labels, tick_positions=None, x_label='', y_label='', title='', legend_names=[], loc=2):
    # plot values
    fig = plt.figure()
    fig.suptitle(title)
    ax = Subplot(fig, 111)
    ax = fig.add_subplot(ax)
    plt.ylabel(y_label)
    plt.xlabel(x_label)
    # plot each dataset
    width = .9/len(bar_list)                      # the width of the bars
    ind = np.array(range(len(bar_list[0])))
    color_list = ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928']
    recs = []
    for i in range(len(bar_list)):
        recs.append(ax.bar(ind + (width * i), bar_list[i], width, color=color_list[i], linewidth=0))
    # calculate where the labels should go
    if tick_positions is not None:
        ax.set_xticks(np.array(tick_positions) + .5)
    else:
        ax.set_xticks(ind + .5)
    xtickNames = ax.set_xticklabels(tick_labels)
    # adjust how the axis shows
    ax.axis["bottom"].major_ticklabels.set_pad(30)
    ax.axis["bottom"].label.set_pad(20)
    ax.axis["bottom"].major_ticklabels.set_rotation(30)
    ax.axis["bottom"].major_ticks.set_visible(False)
    ax.axis["top"].set_visible(False)
    # add a legend
    if len(legend_names) == len(recs):
        legend_names = tuple([ln.title() for ln in legend_names])
        legend_colors = tuple(r[0] for r in recs)
        ax.legend( legend_colors, legend_names, frameon=False, loc=loc )
    
    plt.gcf().subplots_adjust(bottom=0.19)    # adjust the bottom of the plot
    plt.show()
def plot_df_f0s():
    fig = plt.figure(1, (3, 3))

    ax = Subplot(fig, 111)
    fig.add_subplot(ax)

    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)

    x = np.linspace(-333.3, 1498.5, num=55)
    # x = range(1, 56)
    for true_means, list_sems in zip(all_true_means, all_list_sems):
        ax.errorbar(x, true_means, yerr=list_sems, elinewidth=3, linewidth=4)
    ax.axvspan(0, 400, color="y", alpha=0.5, lw=0)
    ax.set_xticks([-200, 0, 200, 400, 600, 800, 1000, 1200, 1400])
    ax.set_xlabel("Time (ms)")
    ax.set_ylabel(r"$\Delta F/F_0$(%)")
    ax.xaxis.set_tick_params(width=2, length=7)
    ax.yaxis.set_tick_params(width=2, length=7)

    # x_axis = np.linspace(3.333, 26.6667, num=800)
    # for df_df0 in list_df_f0:
    # plt.plot(df_df0)
    ax.set_ylim([-1.5, 2.5])
    ax.set_xlim([-340, 1500])

    # axes color.... jeff didn't like it :(
    # plt.axhline(linewidth=3, color='k')
    # plt.axvline(linewidth=3, color='k')

    # plt.xlim([3.333,26.6667])

    # plt.plot([83, 83], [-0.015, 0.025], 'k-', lw=2)
    # plt.plot([203, 203], [-0.015, 0.025], 'k-', lw=2)
    # plt.plot([505, 505], [-0.015, 0.025], 'k-', lw=2)
    # plt.axvspan(5, 17, color='y', alpha=0.5, lw=0)
    # plt.axvspan(505, 517, color='y', alpha=0.5, lw=0)

    # for i in range(1, len(timings)):
    # plt.plot([timings[i], timings[i]], [-0.015, 0.025], 'k-', lw=2)
    plt.show()