Created
August 22, 2023 23:00
-
-
Save senderista/a6ea02c5531fcf84fe37dfc384d9c789 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
#!/usr/local/bin/python3 | |
import sys | |
import numpy as np | |
import pandas as pd | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import warnings; warnings.filterwarnings(action='once') | |
csv_file_name = sys.argv[1] | |
print(csv_file_name) | |
large = 22; med = 16; small = 12 | |
params = {'axes.titlesize': large, | |
'legend.fontsize': med, | |
'figure.figsize': (16, 10), | |
'axes.labelsize': med, | |
'axes.titlesize': med, | |
'xtick.labelsize': med, | |
'ytick.labelsize': med, | |
'figure.titlesize': large} | |
plt.rcParams.update(params) | |
plt.style.use('seaborn-whitegrid') | |
sns.set_style("white") | |
# Import Data | |
df = pd.read_csv(csv_file_name) | |
print(df.to_string()) | |
# Draw Plot | |
plt.figure(figsize=(16,10), dpi= 80) | |
plt.plot('level', 'count', data=df, color='tab:red') | |
# Decoration | |
plt.xlim(0, 32) | |
plt.ylim(0, 900) | |
xtick_location = [x for x in df.level.tolist()] | |
xtick_labels = [x for x in df.level.tolist()] | |
plt.xticks(ticks=xtick_location, labels=xtick_labels, rotation=0, fontsize=12, horizontalalignment='center', alpha=.7) | |
plt.yticks(fontsize=12, alpha=.7) | |
plt.title("Element count in a randomized binary search tree, by level", fontsize=22) | |
plt.xlabel('Levels') | |
plt.ylabel('Count') | |
plt.grid(axis='both', alpha=.3) | |
# Remove borders | |
plt.gca().spines["top"].set_alpha(0.0) | |
plt.gca().spines["bottom"].set_alpha(0.3) | |
plt.gca().spines["right"].set_alpha(0.0) | |
plt.gca().spines["left"].set_alpha(0.3) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment