# Short intro: basic plotting using the periodic table¶

• Complexity level: novice
• Requirements: basic knowledge of chemistry and Python

The reader would probably agree, that the periodic table is crucially important. The chemical elements, as well as the chemical formulae are introduced here. Let's explore this a bit.

We know the inorganic chemical formulae are constructed according to the electronegativities of the chemical elements. Generally, the more the electronegativity value, the more to the right the chemical element in the formula. Although there are some details, concerned with the exact definition of the electronegativity.

Let's plot the Pauling electronegativities vs. periodic numbers of the chemical elements using the popular matplotlib Python library.

In [ ]:
import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('agg')


Now we define the periodic table and electronegativities.

Note that there are several electronegativity scales (see e.g. those given in the mendeleev database). And here we use the Pauling's scale.

The periodic numbers reflect the periodic table proposed by Julius-Lothar Meyer in 1870. How is that different from the well-known one by Dmitry Mendeleev? The rows and columns are exchanged!

In [ ]:
chemical_elements = [
'H',                                                                                                                                                                                      'He',
'Li', 'Be',                                                                                                                                                 'B',  'C',  'N',  'O',  'F',  'Ne',
'Na', 'Mg',                                                                                                                                                 'Al', 'Si', 'P',  'S',  'Cl', 'Ar',
'K',  'Ca',                                                                                     'Sc', 'Ti', 'V',  'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',
'Rb', 'Sr',                                                                                     'Y',  'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I',  'Xe',
'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W',  'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U',  'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']

periodic_numbers = [
1,                                                                                                                                                                                        112,
2,    8,                                                                                                                                                     82,   88,   94,  100,  106,  113,
3,    9,                                                                                                                                                     83,   89,   95,  101,  107,  114,
4,   10,                                                                                        14,    46,   50,   54,   58,   62,   66,   70,   74,   78,   84,   90,   96,  102,  108,  115,
5,   11,                                                                                        15,    47,   51,   55,   59,   63,   67,   71,   75,   79,   85,   91,   97,  103,  109,  116,
6,   12,    16,    18,   20,  22,   24,    26,   28,   30,   32,   34,   36,   38,  40,   42,   44,    48,   52,   56,   60,   64,   68,   72,   76,   80,   86,   92,   98,  104,  110,  117,
7,   13,    17,    19,   21,  23,   25,    27,   29,   31,   33,   35,   37,   39,  41,   43,   45,    49,   53,   57,   61,   65,   69,   73,   77,   81,   87,   93,   99,  105,  111,  118]

electronegativities = [
2.2,                                                                                                                                                                                      0,
0.98, 1.57,                                                                                                                                                 2.04, 2.55, 3.04, 3.44, 3.98, 0,
0.93, 1.31,                                                                                                                                                 1.61, 1.90, 2.19, 2.58, 3.16, 0,
0.82, 1.00,                                                                                     1.36, 1.54, 1.63, 1.66, 1.55, 1.83, 1.88, 1.91, 1.9,  1.65, 1.81, 2.01, 2.18, 2.55, 2.96, 3,
0.82, 0.95,                                                                                     1.22, 1.33, 1.60, 2.16, 1.90, 2.20, 2.28, 2.20, 1.93, 1.69, 1.78, 1.96, 2.05, 2.10, 2.66, 2.6,
0.79, 0.89, 1.1,  1.12, 1.13, 1.14, 1.13, 1.17,  1.2,  1.2,  1.1, 1.22, 1.23, 1.24, 1.25, 1.1,  1.27, 1.30, 1.50, 2.36, 1.90, 2.20, 2.20, 2.28, 2.54, 2.00, 1.62, 2.33, 2.02, 2.00, 2.20, 2.20,
0.70, 0.90, 1.1,  1.30, 1.50, 1.38, 1.36, 1.28,  1.3,  1.3,  1.3, 1.3,  1.3,  1.3,  1.3,  1.3,  1.3,  0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0]


Then we massage our data a little bit adding a summary trend line.

We're good to go:

In [ ]:
%matplotlib inline

points = [pair for pair in zip(electronegativities, periodic_numbers) if pair[0] > 0]
x, y = zip(*points)

fitted_coeffs = np.polyfit(x, y, 1)
fitted_fn = np.poly1d(fitted_coeffs)

fig, ax = plt.subplots(figsize=(15, 10))

ax.set_xlabel('Electronegativity')
ax.set_ylabel('Periodic Number')

ax.scatter(x, y, c='b', s=2, label='Chem. elements')
plt.plot(x, fitted_fn(x), c='g', linewidth=0.5, label='Linear fit')
plt.legend()

for i, label in enumerate(chemical_elements):
ax.annotate(
label,
(electronegativities[i], periodic_numbers[i]),
size=10
)


Look, the whole chemistry is encoded in the resulted figure :)

Were you able to follow everything? Please, try to explain the plot: why it looks specifically like this?