Skip to content

Commit

Permalink
script to make plot now accepts CSV and uses argparse
Browse files Browse the repository at this point in the history
Former-commit-id: 8c5054036c3241d207364d5e9a139b14fd697057
  • Loading branch information
Javi Ribera committed Apr 4, 2018
1 parent c0463c5 commit c279c1c
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions scripts_dataset_and_results/make_pr_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
import argparse

# Parse command-line arguments
parser = argparse.ArgumentParser(
description='Make a Precision and Recall plot from the CSV result',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('csv',
help='CSV file with the precision and recall results.')
parser.add_argument('out',
help='Output plot image.')
parser.add_argument('--title',
default='',
help='Title of the plot in the figure.')
args = parser.parse_args()

# Data extraction
data = pd.read_excel("/Users/dguera/Desktop/test.xlsx")
pr_crowd = data["Precision (crowd)"].as_matrix(range(len(data["Precision (crowd)"])))
r_crowd = data["Recall (crowd)"].as_matrix(range(len(data["Recall (crowd)"])))
r = data["r"].as_matrix(range(len(data["r"])))
df = pd.read_csv(args.csv)
precision = df.precision.values
recall = df.recall.values
r = df.r.values

# Create the figure for "Crowd" Dataset
# Create the figure for "Crowd" Dataset
plt.ioff()
fig, ax = plt.subplots()
precision = ax.plot(r, pr_crowd, 'r--',label='Precision')
recall = ax.plot(r, r_crowd, 'b:',label='Recall')
precision = ax.plot(r, precision, 'r--',label='Precision')
recall = ax.plot(r, recall, 'b:',label='Recall')
ax.legend()
ax.set_ylabel('Percentatge')
ax.set_ylabel('%')
ax.set_xlabel(r'$r$ (in pixels)')
ax.grid(True)
fig.savefig('/Users/dguera/Desktop/plot.eps')
#plt.show()
plt.title(args.title)

# Save to disk
fig.savefig(args.out)

0 comments on commit c279c1c

Please sign in to comment.