doc/sphinx/plots/density_plot.py
raw| 1 | import matplotlib.pyplot as plt |
| 2 | import periodictable |
| 3 | |
| 4 | params = {'figure.figsize': (10,8)} |
| 5 | plt.rcParams.update(params) |
| 6 | |
| 7 | D = [(el.number,el.density,el.symbol) |
| 8 | for el in periodictable.elements] |
| 9 | |
| 10 | bbox = dict(boxstyle="round",lw=1,ec=(0,0,0),fc=(0.85,0.8,0.8)) |
| 11 | for Z,density,sym in D: |
| 12 | if density is not None: |
| 13 | plt.text(Z,density,sym,bbox=bbox) |
| 14 | plt.axis([0,110,0,25]) |
| 15 | plt.xlabel('Element number') |
| 16 | plt.ylabel('Density of element') |
| 17 | plt.title('Density for elements') |