Skip to content

Instantly share code, notes, and snippets.

@anadim
Created March 9, 2024 19:41
Show Gist options
  • Save anadim/7a6886cc5c0eef4920fc27050c836990 to your computer and use it in GitHub Desktop.
Save anadim/7a6886cc5c0eef4920fc27050c836990 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
# Define the performance scores for each column
column1 = [86.8, 88.2, 61.0, 60.1, 73.7, 95.0, 84.9, 50.4, 59.5, 90.7, 83.1, 86.8, 96.4, 95.4, 75.8, 74.9, 88.5, 92.9, 70.2, 86.4]
column2 = [79.0, 81.5, 40.5, 43.1, 55.1, 92.3, 73.0, 40.4, 46.3, 83.5, 78.9, 82.9, 93.2, 89.0, 78.3, 79.7, 75.1, 88.8, 55.9, 79.4]
column3 = [75.2, 76.7, 40.9, 38.9, 50.3, 88.9, 75.9, 33.3, 40.1, 75.1, 78.4, 73.7, 89.2, 85.9, 76.0, 78.5, 74.2, 87.0, 54.8, 80.4]
# Calculate the averages for each column
average_col1 = sum(column1) / len(column1)
average_col2 = sum(column2) / len(column2)
average_col3 = sum(column3) / len(column3)
# Print the averages
print("Average for Column 1:", average_col1)
print("Average for Column 2:", average_col2)
print("Average for Column 3:", average_col3)
# # Average performances for each of the three conditions
# average_col1 = 80.03500000000001
# average_col2 = 71.42105263157895
# average_col3 = 68.09473684210526
# Cost values corresponding to each average performance
p = 0.83
costs = p * np.array([0.25, 3, 15]) + (1 - p) * np.array([1.25, 15,75])
# Set up the figure and axis
plt.figure(figsize=(10, 6))
# Plot the averages on a semi-logarithmic X-axis
plt.semilogx(costs, [average_col3, average_col2, average_col1], marker='o', linestyle='', label='Average Scores from Table 1', markersize = 10)
# Set the axis labels and plot title
plt.xlabel('Cost')
plt.ylabel('Average Performance')
plt.title('Average Performance vs Cost on a Semi-Logarithmic X-axis')
# Set the range for the Y-axis and X-axis
plt.ylim(58, 80.5)
plt.xlim(0.34, 43)
# Define the custom x-ticks as requested
plt.xticks([1, 10], ['1', '10'])
# Turn on the grid for better readability of the plot
# plt.grid(True, which="both", ls="--")
# Add a legend to the plot
plt.legend()
# Show the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment