@@ -125,7 +125,7 @@ fig.show()
125125#### Custom Hovertext
126126
127127``` python
128- # Add Periodic Table Data
128+ # Periodic Table Data
129129symbol = [[' H' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' He' ],
130130 [' Li' , ' Be' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' B' , ' C' , ' N' , ' O' , ' F' , ' Ne' ],
131131 [' Na' , ' Mg' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' Al' , ' Si' , ' P' , ' S' , ' Cl' , ' Ar' ],
@@ -181,7 +181,7 @@ z = [[.8, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, 1.],
181181# Display element name and atomic mass on hover
182182hover= []
183183for x in range (len (symbol)):
184- hover.append([i + ' <br>' + ' Atomic Mass: ' + str (j)
184+ hover.append([i + ' <br>' + ' Atomic Mass: ' + str (j) if i else ' '
185185 for i, j in zip (element[x], atomic_mass[x])])
186186
187187# Invert Matrices
@@ -197,7 +197,12 @@ colorscale=[[0.0, 'rgb(255,255,255)'], [.2, 'rgb(255, 255, 153)'],
197197# Make Annotated Heatmap
198198fig = ff.create_annotated_heatmap(z, annotation_text = symbol, text = hover,
199199 colorscale = colorscale, font_colors = [' black' ], hoverinfo = ' text' )
200- fig.update_layout(title_text = ' Periodic Table' )
200+ fig.update_layout(
201+ title_text = ' Periodic Table' ,
202+ margin = dict (l = 10 , r = 10 , t = 10 , b = 10 , pad = 10 ),
203+ xaxis = dict (zeroline = False , showgrid = False ),
204+ yaxis = dict (zeroline = False , showgrid = False , scaleanchor = " x" ),
205+ )
201206fig.show()
202207```
203208
0 commit comments