Last active
March 17, 2018 10:59
-
-
Save psinger/3d39a0294585ff33aa1f03bf138c891c to your computer and use it in GitHub Desktop.
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
import matplotlib.pyplot as plt | |
import numpy as np | |
def plot_dict(d, xlabel, ylabel, filename): | |
''' Plotting the keys and values given in dictionary | |
d = dictionary | |
xlabel = label for x-axis | |
ylabel = label for y-axis | |
filename = output filename | |
''' | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
ax.plot(d.values(), marker='o') | |
ticks = np.arange(len(d.keys())) | |
ax.set_xticks(ticks) | |
ax.set_xticklabels(d.keys()) | |
ax.set_xlabel(xlabel) | |
ax.set_ylabel(ylabel) | |
plt.savefig(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment