Last active
February 22, 2017 10:04
-
-
Save phizaz/194ac269c3f3e2787ecc78c5b31722f2 to your computer and use it in GitHub Desktop.
Matplotlib: plotting with x-ticks labels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot(keys: list, vals: list): | |
import matplotlib.pyplot as plt | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
x = range(len(vals)) | |
ax.set_xticks(x) # plot every tick | |
ax.set_xticklabels(keys, rotation=90) | |
ax.plot(x, vals) | |
fig.savefig('output.png', bbox_inches='tight') # bbox_inches='tight' to prevent text-overflow out of the frame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment