#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Periodical table
3D view of electronegativity
"""
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
data = np.array([
[2.2,1,0.9,0.8,0.8,0.8,0.7],
[0,1.6,1.3,1,1,0.9,0.9],
[0,0,0,1.4,1.2,1.3,0],
[0,0,0,1.5,1.3,1.3,0],
[0,0,0,1.6,1.6,1.5,0],
[0,0,0,1.6,2.2,2.4,0],
[0,0,0,1.6,1.9,1.9,0],
[0,0,0,1.8,2.2,2.2,0],
[0,0,0,1.9,2.3,2.2,0],
[0,0,0,1.8,2.2,2.3,0],
[0,0,0,1.9,1.9,2.5,0],
[0,0,0,1.6,1.7,2,0],
[0,2,1.6,1.8,1.8,1.6,0],
[0,2.5,1.9,2,1.8,1.8,0],
[0,3,2.2,2.2,2,2,0],
[0,3.5,2.6,2.5,2.1,2,0],
[0,4,3.2,3,2.7,2.2,0],
[0,0,0,0,0,0,0],
])
column_names = ['1','2','3','4','5','6','7']
row_names = ['IA','IIA','IIIB','IVB','VB','VIB','VIIB','VIII','VIII','VIII','IB','IIB','IIIA','IVA','VA','VIA','VIIA','VIIIA']
fig = plt.figure()
ax = Axes3D(fig)
lx= len(data[0]) # Work out matrix dimensions
ly= len(data[:,0])
xpos = np.arange(0,lx,1) # Set up a mesh of positions
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.5, ypos+0.4)
xpos = xpos.flatten() # Convert positions to 1D array
ypos = ypos.flatten()
zpos = np.zeros(lx*ly)
dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = data.flatten()
ax.bar3d(xpos,ypos,zpos, dx, dy, dz, color='b')
#sh()
ax.w_xaxis.set_ticklabels(column_names)
ax.w_yaxis.set_ticklabels(row_names)
ax.set_xlabel('periode')
ax.set_ylabel('Famille')
ax.set_zlabel('Electronegativite')
plt.show()