MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / plotly

Function plotly

test/11.charts.py:297–344  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

295
296
297def plotly():
298 x = list(range(10))
299
300 fig = go.Figure(data=go.Scatter(x=x, y=[i ** 2 for i in x]))
301 html1 = fig.to_html(include_plotlyjs="require", full_html=False)
302
303 fig = go.Figure(data=[go.Scatter(
304 x=[1, 2, 3, 4], y=[10, 11, 12, 13],
305 mode='markers',
306 marker=dict(
307 color=['rgb(93, 164, 214)', 'rgb(255, 144, 14)',
308 'rgb(44, 160, 101)', 'rgb(255, 65, 54)'],
309 opacity=[1, 0.8, 0.6, 0.4],
310 size=[40, 60, 80, 100],
311 )
312 )])
313
314 html2 = fig.to_html(include_plotlyjs="require", full_html=False)
315
316 fig = go.Figure(go.Sankey(
317 arrangement="snap",
318 node={
319 "label": ["A", "B", "C", "D", "E", "F"],
320 "x": [0.2, 0.1, 0.5, 0.7, 0.3, 0.5],
321 "y": [0.7, 0.5, 0.2, 0.4, 0.2, 0.3],
322 'pad': 10}, # 10 Pixels
323 link={
324 "source": [0, 0, 1, 2, 5, 4, 3, 5],
325 "target": [5, 3, 4, 3, 0, 2, 2, 3],
326 "value": [1, 2, 1, 1, 1, 1, 1, 2]}))
327
328 html3 = fig.to_html(include_plotlyjs="require", full_html=False)
329
330 fig = go.Figure(go.Sunburst(
331 labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
332 parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"],
333 values=[10, 14, 12, 10, 2, 6, 6, 4, 4],
334 ))
335 # Update layout for tight margin
336 # See https://plotly.com/python/creating-and-updating-figures/
337 fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
338
339 html4 = fig.to_html(include_plotlyjs="require", full_html=False)
340
341 put_grid([
342 [put_html(html1), put_html(html2)],
343 [put_html(html3), put_html(html4)]
344 ], cell_width='1fr', cell_height='1fr')
345
346
347def target():

Callers 1

targetFunction · 0.85

Calls 2

put_gridFunction · 0.85
put_htmlFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…