Skip to content

Instantly share code, notes, and snippets.

@rocarvaj
Last active April 5, 2016 13:47
Show Gist options
  • Save rocarvaj/6c96e2f6ac60aa108697 to your computer and use it in GitHub Desktop.
Save rocarvaj/6c96e2f6ac60aa108697 to your computer and use it in GitHub Desktop.
Plotting in pandas
# Subplots
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(15,5))
average_change[['primal', 'primal_dsoff', 'dual', 'dual_dsoff']].plot(ax=axes[0])
axes[0].set_ylim(-0.0, 0.4)
axes[0].axhline(0.0, ls='dashed')
axes[0].xaxis.set_ticks(list(average_change.index))
axes[0].set_title("Improvement of bounds and gap of best clone")
axes[0].set_xlabel("Number of clones (k)")
axes[0].set_ylabel("Average improvement")
# Blank subplot
axes[1].axis('off')
# Save to png
fig.savefig("my-fig.png")
plt.close(fig) # so it does not open
# Hide legend
ax.legend_.remove()
# Share axis in subplots
fig, ax = plt.subplot(nrows=2, ncols=2, sharey=True) #or sharex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment