The command

ColorData["Atoms", "Panel"]

indicates RGBColors of atoms by clicking a panel.

As I don't want to reinvent the wheel, I asked myself:

How do I transform ColorData["Atoms", "Panel"] into a click panel for chemical elements, which could be used as an argument for other functions like ElementData[] or IsotopeData[]?

  • 1
    $\begingroup$ What is the question? If this is not a question but instead intended to be instructional for others please edit the post to make it a question (it can be very simple) then post the majority of this as a self-answer. Thanks. $\endgroup$
    – Mr.Wizard
    Jul 19, 2014 at 7:23
  • 2
    $\begingroup$ @Mr.Wizard: Thx, I followed your suggestions, and brought it in Q&A form. $\endgroup$
    – hieron
    Jul 24, 2014 at 5:33
  • $\begingroup$ You will notice that you already have a combined four votes. :-) $\endgroup$
    – Mr.Wizard
    Jul 24, 2014 at 6:19

2 Answers 2


simple version

With a single codeline, ColorData["Atoms", "Panel"], can be transformed in a click panel for ElementData[].

{ColorData["Atoms", "Panel"] // 
  ReplaceAll[#, RuleDelayed[ "MouseClicked", $_] :> 
      atomClicked = Part[RuleDelayed["MouseClicked", $], 
       2, 2, 2, 1, 1, 1]])] &, 
 Dynamic[atomClicked, Initialization :> (atomClicked = "H")]

simple click panel for periodic table

changing size or removing panel

Now it would be nice to change the panel size.This could be done simply by using

... // Magnify[#, 2] &

but maybe not the best solution.Therefore I added another function, which replaces ImageSize in Graphics.

(*version2 >>> shows how to remove the panel and how to change image size*)
atomClicked = "H";(*init>>>important*)
imageSize[size_] := 
   Graphics[x_, {y__}] :> Graphics[x, {ImageSize -> size, y}]] &;
atomClickedFunction = 
      "MouseClicked", $_] :> (RuleDelayed["MouseClicked", 
       atomClicked = 
        Part[RuleDelayed["MouseClicked", $], 2, 2, 2, 1, 1, 1]])] &;
{ColorData["Atoms", "Panel"] // atomClickedFunction // imageSize@600 //
      First (*removes Panel*), atomClicked, 
    ElementData[atomClicked, "AlternateStandardNames" (* >>>
     Latin names,
     only for Latin abbreviations available in ElementData[]*)], 
    ElementData[atomClicked, "AtomicNumber"], 
    ElementData[atomClicked, "StandardName"], 
    ElementData[atomClicked, "DiscoveryYear"], 
    ElementData[atomClicked, "DiscoveryCountries"]} // Column // 
  Framed // Dynamic

a clickPanel for ElementData[ ] now

Transformed in a clickPanel for ElementData[ ] now.

Implementing the code in form of a Module[] with optionPatterns and more ... could be the next step ...

Just an idea ...


I recently needed to do something like this. Here's a simplified version of what I came up with:

DynamicModule[{elem = "Hydrogen"}, 
              Panel[Row[{(ColorData["Atoms", "Panel"] /. 
              HoldPattern["MouseClicked" :> rhs_] :> ("MouseClicked" :> (elem = 
              CanonicalName[ElementData[Cases[Unevaluated[rhs], _Rule, ∞][[1, 1]]]]))) /. 
              g_Graphics :> Append[g, ImageSize -> Large] /.
              Panel[stuff_, __] :> stuff, Spacer[20], 
              Dynamic[Grid[Transpose[{Style[#, Bold] & /@
                           {"name:", "symbol:", "atomic number:", "atomic weight:",
                            "phase:", "electron configuration:"}, 
                           Table[ElementData[elem, prop],
                                 {prop, {"Name", "Symbol", "AtomicNumber", "AtomicWeight",
                                         "Phase", "ElectronConfigurationString"}}] /.
                           {e_EntityClass :> ToLowerCase[CanonicalName[e]], 
                            m_Missing :> ToLowerCase[First[m]], 
                            q_Quantity :> QuantityMagnitude[q]}}], Alignment -> Left], 
                      TrackedSymbols :> {elem}]}]]]

interactive periodic table

  • 1
    $\begingroup$ Very nice! The answer reminds me of the chemical knowledge I learned in high school seven years ago. Especially, the priority of 3d>4s that about electron configuration. $\endgroup$
    – xyz
    May 23, 2016 at 3:38
  • 2
    $\begingroup$ @J.M. beautiful, useful and instructive (Mma wise). :) $\endgroup$
    – ubpdqn
    May 24, 2016 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.