Color Scales

Materials Project Element Occurrence Counts

1 H 82.6k
2 He 8
3 Li 69.3k
4 Be 3.37k
5 B 24.2k
6 C 32.2k
7 N 38.5k
8 O 724k
9 F 65.4k
10 Ne 1
11 Na 20.8k
12 Mg 86.9k
13 Al 26.6k
14 Si 30.8k
15 P 47.9k
16 S 52.5k
17 Cl 26.9k
18 Ar 2
19 K 16.1k
20 Ca 17.1k
21 Sc 4.76k
22 Ti 17.3k
23 V 21.6k
24 Cr 13.9k
25 Mn 34.9k
26 Fe 37.9k
27 Co 29.6k
28 Ni 24.4k
29 Cu 22.2k
30 Zn 13.4k
31 Ga 13k
32 Ge 14.2k
33 As 8.94k
34 Se 24.8k
35 Br 12.2k
36 Kr 26
37 Rb 9.08k
38 Sr 16.1k
39 Y 8.75k
40 Zr 8.17k
41 Nb 10.9k
42 Mo 13.2k
43 Tc 1.12k
44 Ru 5k
45 Rh 6.3k
46 Pd 7.19k
47 Ag 8.22k
48 Cd 6.7k
49 In 8.71k
50 Sn 12.5k
51 Sb 12.1k
52 Te 13.5k
53 I 11.8k
54 Xe 303
55 Cs 7.27k
56 Ba 18.1k
57 La 12.6k
58 Ce 5.93k
59 Pr 6.12k
60 Nd 6.9k
61 Pm 822
62 Sm 5.89k
63 Eu 3.69k
64 Gd 2.76k
65 Tb 4.54k
66 Dy 4.59k
67 Ho 4.49k
68 Er 4.71k
69 Tm 3.37k
70 Yb 4.39k
71 Lu 3.06k
72 Hf 4.41k
73 Ta 6.01k
74 W 9.35k
75 Re 3.01k
76 Os 2.19k
77 Ir 4.08k
78 Pt 5.19k
79 Au 5.09k
80 Hg 5.45k
81 Tl 5.53k
82 Pb 6.82k
83 Bi 11.7k
84 Po 0
85 At 0
86 Rn 0
87 Fr 0
88 Ra 0
89 Ac 496
90 Th 1.94k
91 Pa 374
92 U 4.54k
93 Np 577
94 Pu 740
95 Am 0
96 Cm 0
97 Bk 0
98 Cf 0
99 Es 0
100 Fm 0
101 Md 0
102 No 0
103 Lr 0
104 Rf 0
105 Db 0
106 Sg 0
107 Bh 0
108 Hs 0
109 Mt 0
110 Ds 0
111 Rg 0
112 Cn 0
113 Nh 0
114 Fl 0
115 Mc 0
116 Lv 0
117 Ts 0
118 Og 0
57-71 La-Lu Lanthanides
89-103 Ac-Lr Actinides
1101001k10k100k1M
  <script>
  import { ColorBar, ColorScaleSelect, PeriodicTable, TableInset } from 'matterviz'
  import { format_num } from 'matterviz/labels'
  import mp_elem_counts from './mp-element-counts.json'
  import wbm_elem_counts from './wbm-element-counts.json'

  let log_scale = $state(true)
  let data_name = $state(`MP`)
  let color_scale = $derived(`interpolateViridis`)
  let heatmap_values = $derived(
    Object.values(data_name == `WBM` ? wbm_elem_counts : mp_elem_counts),
  )
  let total = $derived(heatmap_values.reduce((a, b) => a + b, 0))
  let nice_range = $state([])
</script>

<h1 style="text-align: center">Color Scales</h1>

<h2 style="text-align: center">
  {{ MP: `Materials Project` }[data_name] ?? data_name} Element Occurrence Counts
</h2>

<PeriodicTable
  {heatmap_values}
  log={log_scale}
  {color_scale}
  bind:color_scale_range={nice_range}
>
  {#snippet inset({ active_element })}
    <TableInset>
      <section>
        <span>
          Data set &ensp;
          {#each [`MP`, `WBM`] as data_set}
            <input type="radio" bind:group={data_name} value={data_set} /> {data_set}
          {/each}
        </span>
        <span>Log color scale <input type="checkbox" bind:checked={log_scale} /></span>
        <ColorScaleSelect bind:value={color_scale} selected={[color_scale]} />
      </section>
      <strong style="height: 25pt">
        {#if active_element?.name}
          {@const elem_counts = data_name == `WBM` ? wbm_elem_counts : mp_elem_counts}
          {active_element?.name}: {format_num(elem_counts[active_element?.symbol])}
          <!-- compute percent of total -->
          {#if elem_counts[active_element?.symbol] > 0}
            ({format_num(elem_counts[active_element?.symbol] / total, `.2~%`)})
          {/if}
        {/if}
      </strong>
    </TableInset>
  {/snippet}
</PeriodicTable>

<ColorBar
  range={[1, Math.max(...heatmap_values)]}
  {color_scale}
  bind:nice_range
  scale_type={log_scale ? `log` : `linear`}
  bar_style="width: 100%; margin: 4em 1em"
/>