Skip to content

Instantly share code, notes, and snippets.

@DanielTakeshi
Last active June 16, 2021 21:56
Show Gist options
  • Select an option

  • Save DanielTakeshi/a4a8c431bd3ab30ed578f3b579083c7a to your computer and use it in GitHub Desktop.

Select an option

Save DanielTakeshi/a4a8c431bd3ab30ed578f3b579083c7a to your computer and use it in GitHub Desktop.

Revisions

  1. DanielTakeshi revised this gist Jun 16, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,4 @@ fig.legend(
    plt.tight_layout()
    plt.subplots_adjust(bottom=0.20)
    figname = f'plot_testpng'
    plt.savefig(figname)(spinningup)
    plt.savefig(figname)
  2. DanielTakeshi created this gist Jun 16, 2021.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    plt.style.use('seaborn')
    import numpy as np

    nrows, ncols = 1, 2
    fig, ax = plt.subplots(nrows, ncols, sharey=False, squeeze=True, figsize=(9*ncols, 6*nrows))
    x = np.arange(100)
    y0 = x + np.random.normal(loc=0.0, scale=10.0, size=100)
    y1 = x + np.random.normal(loc=0.0, scale=10.0, size=100)
    y2 = x + np.random.normal(loc=0.0, scale=5.0, size=100)
    ax[0].plot(x, y2, ls='-', lw=4 ,color='blue')
    l1, = ax[0].plot(x, y0, ls='-', lw=4 ,color='red')
    l2, = ax[1].plot(x, y1, ls='-', lw=4, color='blue')
    # Note: not sure why we need the comma here ...

    fig.legend(
    handles=[l1, l2],
    labels=['Red Data', 'Blue Data'],
    loc='lower left',
    prop={'size': 30},
    bbox_to_anchor=(0.30, 0.0),
    ncol=2,
    shadow=True,
    frameon=True,
    )

    plt.tight_layout()
    plt.subplots_adjust(bottom=0.20)
    figname = f'plot_testpng'
    plt.savefig(figname)(spinningup)