Skip to content

Commit 6a023af

Browse files
Merge pull request #3489 from janosh/periodic-table-example
Improve Periodic-table-example
2 parents 0675fc1 + 29c66cb commit 6a023af

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Diff for: doc/python/annotated-heatmap.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fig.show()
159159
Here is a fairly contrived example showing how one can display a periodic table with custom text and hover using `ff.create_annotated_heatmap()` (scroll below to see the `px.imshow()` equivalent).
160160

161161
```python
162-
# Add Periodic Table Data
162+
# Periodic Table Data
163163
symbol = [['H', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'He'],
164164
['Li', 'Be', '', '', '', '', '', '', '', '', '', '', 'B', 'C', 'N', 'O', 'F', 'Ne'],
165165
['Na', 'Mg', '', '', '', '', '', '', '', '', '', '', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar'],
@@ -220,14 +220,19 @@ colorscale=[[0.0, 'rgb(255,255,255)'], [.2, 'rgb(255, 255, 153)'],
220220
# Display element name and atomic mass on hover
221221
hover=[]
222222
for x in range(len(symbol)):
223-
hover.append([i + '<br>' + 'Atomic Mass: ' + str(j)
223+
hover.append([i + '<br>' + 'Atomic Mass: ' + str(j) if i else ''
224224
for i, j in zip(element[x], atomic_mass[x])])
225-
225+
226226
import plotly.figure_factory as ff
227227
# Make Annotated Heatmap
228228
fig = ff.create_annotated_heatmap(color[::-1], annotation_text=symbol[::-1], text=hover[::-1],
229229
colorscale=colorscale, font_colors=['black'], hoverinfo='text')
230-
fig.update_layout(title_text='Periodic Table')
230+
fig.update_layout(
231+
title_text='Periodic Table',
232+
margin=dict(l=10, r=10, t=10, b=10, pad=10),
233+
xaxis=dict(zeroline=False, showgrid=False),
234+
yaxis=dict(zeroline=False, showgrid=False, scaleanchor="x"),
235+
)
231236
fig.show()
232237
```
233238

Diff for: doc/python/sunburst-charts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ data = dict(
4848
parent=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
4949
value=[10, 14, 12, 10, 2, 6, 6, 4, 4])
5050

51-
fig =px.sunburst(
51+
fig = px.sunburst(
5252
data,
5353
names='character',
5454
parents='parent',

0 commit comments

Comments
 (0)