rocarvaj
3/17/2016 - 4:49 PM

Plotting in pandas

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