Created
October 19, 2016 17:49
-
-
Save jhjensen2/40d0de186f688137d5538ea6f19bbb26 to your computer and use it in GitHub Desktop.
This file contains 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
#making a strip plot from a csv file using seaborn | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import pandas as pd | |
import csv | |
import sys | |
filename = sys.argv[1] | |
reader = csv.DictReader(open(filename)) | |
my_data = {} | |
for row in reader: | |
for column, value in row.iteritems(): | |
my_data.setdefault(column, []).append(value) | |
print my_data | |
# Format into dictionary | |
methods_list = [] | |
error_list = [] | |
#for key in my_data: #for some reason the order is screwed up using this option | |
for key in ["NULL", "PM6-DH+/C", "PM6/C", "PM3/C", "AM1/C", "PM3/S", "AM1/S", "DFTB3/S"] : | |
for data in my_data[key]: | |
methods_list.append(key) | |
error_list.append(data) | |
method_error = dict() | |
method_error["method"] = methods_list | |
method_error["error"] = error_list | |
# Save as panda data frame | |
my_data_formatted = pd.DataFrame(method_error) | |
# Print to see format | |
#print my_data_formatted | |
sns.stripplot(x="method", y="error", data=my_data_formatted, jitter=True, | |
palette="Set2",split=True,linewidth=1,edgecolor='gray') | |
out = filename[:-4]+".png" | |
plt.savefig(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment