Skip to content
Snippets Groups Projects
Commit ca82ce11 authored by Paul Best's avatar Paul Best
Browse files

descent plot

parent 758deb99
No related branches found
No related tags found
No related merge requests found
File added
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib import colors
import pandas as pd, numpy as np
from metadata import species
#colors = ['#006BA4', '#FF800E', '#ABABAB', '#595959', '#5F9ED1', '#C85200', '#898989', '#A2C8EC', '#FFBC79', '#CFCFCF']
colors = list(colors.TABLEAU_COLORS)
# plt.rcParams['legend.title_fontsize'] = 'x-small'
markers = [
('o', 'right', colors[0]), ('d', 'none', colors[0]),
('s', 'none', colors[1]), ('v', 'none', colors[1]), ('H', 'none', colors[1]),
('<', 'none', colors[2]), ('>', 'none', colors[2]), ('^', 'none', colors[2]), ('p', 'none', colors[2]),
('P', 'none', colors[3]), ('*', 'none', colors[3]), ('X', 'none', colors[3]), ('D', 'none', colors[3]) , ('h', 'left', colors[3])]
species_list = [
'wolves', 'spotted_hyenas', # 2 good salience & harmonicity
'bottlenose_dolphins', 'rodents', 'little_owls', # 3 good salience only
'monk_parakeets', 'lions', 'orangutans', 'long-billed_hermits', # 4 good harmonicity only
'hummingbirds', 'disk-winged_bats', 'Reunion_grey_white_eyes', 'dolphins', 'La_Palma_chaffinches'] # 5 neither
algos = ['basic', 'pyin', 'pesto', 'praat', 'pesto_ft', 'tcrepe_ftoth', 'tcrepe_ftsp']
algo_names = ['basic', 'pyin', 'pesto-music', 'praat', 'pesto-bio', 'crepe-other', 'crepe-target']
metrics = ['Pitch acc'] #, 'Chroma acc']
# metrics = ['Recall', 'Specificity', 'Vocalisation recall']
fig, ax = plt.subplots(nrows=1, ncols=len(metrics), figsize=(10, 4.5), sharex=True, sharey=True)
#ax[0].set_yticks([0, .2, .4, .6, .8, 1])
ax.set_ylim(0, 1)
algo_legend = []
for i, metric in enumerate(metrics):
m_ax = ax #ax[int(i//2), i%2]
m_ax.grid('both', axis='y')
m_ax.set_ylabel(metric, fontsize='medium')
ok = pd.DataFrame()
for j, (specie, marker) in enumerate(zip(species_list, markers)):
df = pd.read_csv(f'scores/{specie}_scores.csv', index_col=0)
df['Specificity'] = 1 - df['False alarm']
df.rename(columns={'Voc. recall':'Vocalisation recall'}, inplace=True)
ok.loc[specie, df.index] = df[metric]
tt = m_ax.plot(np.arange(len(algos))-.3+j*0.6/len(species_list), ok.loc[specie, algos], marker=marker[0], color=marker[2], fillstyle=marker[1], markersize=8, label=specie.replace('_',' '), linestyle='none')
algo_legend.append(tt[0])
m_ax.set_xticks(range(len(algo_names)))
m_ax.set_xticklabels(algo_names)
#ax[1].set_xticklabels(algos, rotation=22)
plt.tight_layout(rect=(0, 0, 1, .87))
species_list = [s.replace('_', ' ') for s in species_list]
leg = ax.legend(algo_legend[:2], species_list[:2], title='salient & harmonic', loc='lower left', bbox_to_anchor=(0, 1.02), fontsize='x-small')
ax.add_artist(leg)
leg = ax.legend(algo_legend[2:5], species_list[2:5], title='salient & non-harmonic', loc='lower left', bbox_to_anchor=(0.16, 1.02), fontsize='x-small')
ax.add_artist(leg)
leg = ax.legend(algo_legend[5:9], species_list[5:9], ncols=2, title='non-salient & harmonic', loc='lower left', bbox_to_anchor=(0.36, 1.02), fontsize='x-small')
ax.add_artist(leg)
leg = ax.legend(algo_legend[9:], species_list[9:], ncols=2, title='non-salient & non-harmonic', loc='lower left', bbox_to_anchor=(0.65, 1.02), fontsize='x-small')
ax.add_artist(leg)
# ax.legend(loc='lower left', ncols=7, bbox_to_anchor=(0, 1.1), fontsize='x-small')
plt.savefig(f'figures/scatter_scores_columns.pdf')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment