Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot_dendogram(df_one_race, filename):
- # Data prep
- df = df_one_race.drop(index_list, axis=1)
- X = df.as_matrix(columns=None)
- Z = linkage(X, 'ward')
- # call dendrogram to get the returned dictionary (plotting parameters can be ignored at this point)
- R = dendrogram(
- Z,
- no_plot=True,
- )
- # create a label dictionary
- labels = df_one_race.driverRef
- temp = {R["leaves"][ii]: labels[ii] for ii in range(len(R["leaves"]))}
- def llf(xx):
- return "{}".format(temp[xx])
- dendrogram(
- Z,
- leaf_label_func=llf,
- leaf_rotation=90.,
- leaf_font_size=8.,
- )
- plt.title('Dendrogram')
- plt.xlabel('Drivers')
- plt.ylabel('Distance')
- plt.savefig(directory+filename, bbox_inches='tight', facecolor='w', transparent=False, pad_inches = 0.5)
- plt.show()
Add Comment
Please, Sign In to add comment