Skip to content

Instantly share code, notes, and snippets.

@MauricioLetelier
Created June 14, 2020 00:29
Show Gist options
  • Save MauricioLetelier/08e18dbc47869181b0098d7c88bb6a37 to your computer and use it in GitHub Desktop.
Save MauricioLetelier/08e18dbc47869181b0098d7c88bb6a37 to your computer and use it in GitHub Desktop.
Results=Results[(Results['Combination']=='1.5, -1.5') & (Results['P(p)>']>0.47) & (Results['P(p)>']<0.72)]
from matplotlib import cm
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
sns.set(font_scale=1.1)
sns.set_style('dark')
pastel=cm.get_cmap('Pastel1',len(Results))
diverging=cm.get_cmap('RdYlGn',len(Results))
plt.figure(figsize=(14,8))
plt.bar(x=Results['P(p)>'], height=Results['Success rate'],width=0.005,color= pastel(np.linspace(0,1,len(Results))))
plt.ylabel('Success Rate')
plt.xlabel('P(p)>')
for index, row in Results.iterrows():
plt.text(
row['P(p)>'],
row["Success rate"],
int(row.Quantity),
fontsize=12,
color="black",
ha="center",
)
axes2 = plt.twinx()
axes2.scatter(Results['P(p)>'], Results['Return'], color=diverging(scaler.fit_transform(np.array(Results['Return']).reshape(-1,1)).reshape(len(Results),1)).reshape(len(Results),4),s=200)
axes2.plot(Results['P(p)>'], Results['Return'],lw=0.3,color='grey')
axes2.set_ylabel('Return',color='red')
plt.xticks(Results['P(p)>'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment