dailylog 7-18-20

less than 1 minute read

THINGS I LEARNED

THINGS I MADE

Color Dictionary

color_dict sns add color to scatter plot

color_dict = dict({1:’#D4E6F1’, 2:’#7FB3D5’, 3: ‘#2980B9’, 4: ‘#1F618D’})

plt.figure(figsize=(10,6), dpi=300) df = og_df.copy() df=df.rename(columns = {‘ipf_binned’:’performance’}) for dept in set(df.dept_binned): # df.columns = [col for col in df.columns if col not]

sm_df = df[df.dept_binned == dept]
plt.style.use('default')

plt.style.use(“seaborn-darkgrid”)

colors = ['#1F618D','#2980B9','#7FB3D5','#D4E6F1', '#D4E6F1']
customPalette = sns.set_palette(sns.color_palette(colors))
ax = sns.scatterplot(x="wage_numeric", y="years_active",
                     hue="performance", size="performance",
                     size_order=['yes', 'no'],
                     sizes=(20, 150),
                     legend="full", data=sm_df, palette=color_dict)

plt.title('Tenure, Salary and Performance for '+dept)
plt.xlabel('Salary')
plt.ylabel('Tenure')
plt.legend(loc='upper left', bbox_to_anchor=(1, 1))
plt.show()

STACKED BAR GRAPH WITH ANNOTATIONS

# col_dict = {}
col_dict = dict(zip(range(0,len(engineering_g.values)),[0]*len(engineering_g.values)))
ax = engineering_g.plot.barh(stacked=True)
for col in engineering_g.columns:
    for i, v in enumerate(engineering_g[col]):
        col_dict[i] = col_dict[i] + v
#         print(i, col_dict[i])
        print(i,v)
        new_v = col_dict[i]
#         print(new_v)
#         print(v,i,str(v))
        v_text = str(round(v))
        if(v!=0):
            ax.text(new_v-len(v_text), i," "+v_text, color='white', va='center', fontweight='bold', fontsize='8')
plt.show()