Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only Cobalt has color? #48

Closed
twilsonco opened this issue Nov 12, 2022 · 1 comment
Closed

Only Cobalt has color? #48

twilsonco opened this issue Nov 12, 2022 · 1 comment

Comments

@twilsonco
Copy link

color is missing for everything but Cobalt

Attempting to use PeriodicTable to color scatter points in a plot from imported computational chemistry charge density grid data, I noticed that all colors returned an empty string.
image

Looking into it, color is only set for Cobalt:
image

Workaround and proposed solution

As a workaround, I'm using the following list of hex rgb colors (that I got from https://sciencenotes.org/molecule-atom-colors-cpk-colors/) that can be used when plotting.

Conceptually, the color field should IMO return the conventional color used to represent the element. This list of colors should be used to set the color of each element, since the colors are missing from https://github.com/Bowserinator/Periodic-Table-JSON/blob/master/PeriodicTableJSON.json

I'd be happy to PR this.

atom_colors = ("#FFFFFF","#D9FFFF","#CC80FF","#C2FF00","#FFB5B5","#909090","#3050F8",
               "#FF0D0D","#90E050","#B3E3F5","#AB5CF2","#8AFF00","#BFA6A6","#F0C8A0",
               "#FF8000","#FFFF30","#1FF01F","#80D1E3","#8F40D4","#3DFF00","#E6E6E6",
               "#BFC2C7","#A6A6AB","#8A99C7","#9C7AC7","#E06633","#F090A0","#50D050",
               "#C88033","#7D80B0","#C28F8F","#668F8F","#BD80E3","#FFA100","#A62929",
               "#5CB8D1","#702EB0","#00FF00","#94FFFF","#94E0E0","#73C2C9","#54B5B5",
               "#3B9E9E","#248F8F","#0A7D8C","#006985","#C0C0C0","#FFD98F","#A67573",
               "#668080","#9E63B5","#D47A00","#940094","#429EB0","#57178F","#00C900",
               "#70D4FF","#FFFFC7","#D9FFC7","#C7FFC7","#A3FFC7","#8FFFC7","#61FFC7",
               "#45FFC7","#30FFC7","#1FFFC7","#00FF9C","#00E675","#00D452","#00BF38",
               "#00AB24","#4DC2FF","#4DA6FF","#2194D6","#267DAB","#266696","#175487",
               "#D0D0E0","#FFD123","#B8B8D0","#A6544D","#575961","#9E4FB5","#AB5C00",
               "#754F45","#428296","#420066","#007D00","#70ABFA","#00BAFF","#00A1FF",
               "#008FFF","#0080FF","#006BFF","#545CF2","#785CE3","#8A4FE3","#A136D4",
               "#B31FD4","#B31FBA","#B30DA6","#BD0D87","#C70066","#CC0059","#D1004F",
               "#D90045","#E00038","#E6002E","#EB0026","#FF00A0","#FF00A0","#FF00A0",
               "#FF00A0","#FF00A0","#FF00A0","#FF00A0","#FF00A0","#FF00A0")

Partial demonstration of workaround

In my case this looks like this:

atoms = [Dict("data" => elements[atom_num], 
                  "color" => atom_colors[atom_num],
                  "r" => atom_xyz)

then

r = invert([a["r"] for a in sys["atoms"]])
plot(scatter(x=r[1], y=r[2], z=r[3], 
                mode="markers", type="scatter3d", legend=false,
                marker=attr(color=[a["color"] for a in sys["atoms"]]), 
                line=attr(color="black", width=3))
                )
@twilsonco
Copy link
Author

I'm an idiot. The field for the representative color isn't color, it's cpk_hex and is populated correctly for all elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant