Color Scales
Materials Project Element Occurrence Counts
2 He 8
10 Ne 1
18 Ar 2
36 Kr 26
54 Xe 303
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
86 Rn 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
118 Og 0
57-71 La-Lu Lanthanides
89-103 Ac-Lr Actinides
<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  
{#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"
/>