I know you said you didn't want to reinvent the wheel, but sometimes, it's fun to do so. The code below creates a palette with a Periodic Table and a few buttons to make useful tool tips. It shows how one might change the colors based on properties grabbed from ElementData
. Note that this code was written for version 9, and if you wish to use it in version 10, you must first execute:
SetSystemOptions[SystemOptions["DataOptions"] /. True -> False]
Pardon some of the obfuscatory symbols; the code originates from my (failed) attempt to create a tweetable interactive periodic table.
CreatePalette[Manipulate[
Column[{
Evaluate[Grid[Table[{i, j}, {i, 7}, {j, 18}]]] /.
Thread[
Evaluate[
Partition[
MapThread[ElementData[#1, #2] &,
Transpose[Tuples[{Range[112], {"Period", "Group"}}]]],
2]] -> Evaluate[
Item[Tooltip[ElementData[#, "Symbol"],
ElementData[#, popup]], Background -> color[#],
Frame -> True] & /@ Range[112]]] /. {{_, _} -> ""},
Grid[{Item[
Tooltip[ElementData[#, "Symbol"], ElementData[#, popup]],
Background -> color[#]] & /@ Range[57, 70],
Item[Tooltip[ElementData[#, "Symbol"], ElementData[#, popup]],
Background -> color[#]] & /@ Range[89, 102]}, Frame -> All]
}, Alignment -> Center, Spacings -> {0, 1},
BaseStyle -> {FontSize -> 10}],
{{popup, "Name", "Show me the:"}, {"Name",
"AtomicNumber" -> "Atomic number", "AtomicMass" -> "Atomic mass",
"ElectronConfigurationString" ->
"\!\(\*SuperscriptBox[\(e\), \(-\)]\) config"}},
{{color, bcd, "Color by"}, {ncd -> Tooltip["None", "No color"],
bcd -> Tooltip["Block", "s,p,d,f"],
pcd -> Tooltip["Phase", "Solid, Liquid, Gas"],
mcd -> Tooltip["Metal", "Metal, Nonmetal, Metalloid"]}},
Initialization :> {
ncd[x_] := White;
bcd[x_] :=
ColorData[11][
ElementData[x, "Block"] /. {"s" -> 1, "p" -> 2, "d" -> 3,
"f" -> 4}];
pcd[x_] :=
ColorData[13][
Switch[ElementData[x, "Phase"], "Gas", 6, "Liquid", 2, "Solid",
1, _, 5]];
mcd[x_] :=
Which[#[[1]], LightBlue, #[[2]], LightGreen, #[[3]], LightRed] &[
MemberQ[ElementData[x, "Memberships"], #] & /@ {"Metal",
"Nonmetal", "Metalloid"} ];
}], WindowTitle -> "Periodic Table"]
The part that is relevant to you is in the Initialization
rule where I define ncd
, bcd
, pcd
, and mcd
. ncd
sets all elements to the same color, bcd
uses the block pulled from ElementData
, and the last two pull characteristics from ElementData
as well, using that information in slightly different ways. Hope this is helpful to someone.
ColorData["Atoms","Panel"]
andElementData[element,"IconColor"]
are not the same colors in general. There are slight differences. $\endgroup$