Skip to content

Instantly share code, notes, and snippets.

@MonikaPdb
Created December 10, 2017 12:11
Show Gist options
  • Save MonikaPdb/c8c2fc808c89ea5e34808fb55f74f37a to your computer and use it in GitHub Desktop.
Save MonikaPdb/c8c2fc808c89ea5e34808fb55f74f37a to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
header = ['monthly income','job role','marital status','overtime','stock option level', 'age']
dataset = [(100, 0, 80, 85, 86.7, 100),(0, 3.3, 16.7, 15, 10, 0), (0, 31.7, 3.3, 0, 0, 0), (0, 0, 0, 0, 3.3, 0), (0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0), (0, 20, 0, 0, 0, 0),(0, 15, 0, 0, 0, 0), (0, 30, 0, 0, 0, 0) ]
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(18.5, 10.5)
configs = dataset[0]
N = 6
ind = np.arange(N)
width = 0.7
p1 = plt.bar(ind, dataset[0], width, color='#7030A2')
p2 = plt.bar(ind, dataset[1], width, bottom=dataset[0], color='#FD5854')
p3 = plt.bar(ind, dataset[2], width,
bottom=np.array(dataset[0])+np.array(dataset[1]), color='#EA5FC2')
p4 = plt.bar(ind, dataset[3], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2]),
color='#CE2BA9')
p5 = plt.bar(ind, dataset[4], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2])+np.array(dataset[3]),
color='#F6AEF0')
p6 = plt.bar(ind, dataset[5], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2])+np.array(dataset[3])+np.array(dataset[4]),
color='#9052BC')
p7 = plt.bar(ind, dataset[6], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2])+np.array(dataset[3])+np.array(dataset[4])+np.array(dataset[5]),
color='#BF9BB5')
p8 = plt.bar(ind, dataset[7], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2])+np.array(dataset[3])+np.array(dataset[4])+np.array(dataset[5])+np.array(dataset[6]),
color='#822240')
p9 = plt.bar(ind, dataset[8], width,
bottom=np.array(dataset[0])+np.array(dataset[1])+np.array(dataset[2])+np.array(dataset[3])+np.array(dataset[4])+np.array(dataset[5])+np.array(dataset[6])+np.array(dataset[7]),
color='#AF5D71')
plt.text(-0.21,50, '3350', color='white', fontsize=25, fontweight='bold')
plt.text(0.92, 1, 'HR', color='black', fontsize=13, fontweight='bold')
plt.text(0.73, 22, 'Laboratory', color='black', fontsize=15, fontweight='bold')
plt.text(0.73, 18, 'Technician', color='black', fontsize=15, fontweight='bold')
plt.text(0.76, 45, 'Research', color='black', fontsize=15, fontweight='bold')
plt.text(0.78, 41, 'Scientist', color='black', fontsize=15, fontweight='bold')
plt.text(0.85, 63, 'Sales', color='white', fontsize=15, fontweight='bold')
plt.text(0.75, 59, 'Executive', color='white', fontsize=15, fontweight='bold')
plt.text(0.735, 84, 'Sales Rep', color='black', fontsize=16, fontweight='bold')
plt.text(1.73, 45, 'Single', color='white', fontsize=25, fontweight='bold')
plt.text(1.7, 87, 'Married', color='black', fontsize=23, fontweight='bold')
plt.text(1.78, 97.5, 'Divorced', color='black', fontsize=13, fontweight='bold')
plt.text(2.82, 45, 'Yes', color='white', fontsize=30, fontweight='bold')
plt.text(2.87, 90, 'No', color='black', fontsize=25, fontweight='bold')
plt.text(3.7, 45, 'Level 0', color='white', fontsize=23, fontweight='bold')
plt.text(3.7, 90, 'Level 1', color='black', fontsize=23, fontweight='bold')
plt.text(3.82, 97.5, 'Level 3', color='black', fontsize=13, fontweight='bold')
plt.text(4.87,50, '29', color='white', fontsize=30, fontweight='bold')
plt.title('Average leaver', fontsize=30)
plt.ylim([0,110])
plt.yticks(ind,"")
plt.xticks(ind, header, fontsize=15, rotation=0)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment