Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import dash
  5. import dash_core_components as dcc
  6. import dash_html_components as html
  7.  
  8. import plotly.graph_objs as go
  9.  
  10. import pandas as pd
  11. import math
  12.  
  13. # задаем данные для отрисовки
  14. x = range(-100, 100, 1)
  15. x = [x / 10 for x in x]
  16. y_sin = [math.sin(x) for x in x]
  17. y_cos = [math.cos(x) for x in x]
  18. data = [
  19. go.Scatter(x = pd.Series(x), y = pd.Series(y_sin), mode = 'lines', name = 'sin(x)'),
  20. go.Scatter(x = pd.Series(x), y = pd.Series(y_cos), mode = 'lines', name = 'cos(x)'),
  21. ]
  22.  
  23. # задаем лейаут
  24. external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
  25. app = dash.Dash(__name__, external_stylesheets=external_stylesheets,compress=False)
  26. app.layout = html.Div(children=[
  27.  
  28. # формируем html
  29. html.H1(children = 'Тригонометрические функции'),
  30.  
  31. dcc.Graph(
  32. figure = {'data': data,
  33. 'layout': go.Layout(xaxis = {'title': 'x'}, yaxis = {'title': 'y'})
  34. },
  35. id = 'trig_func'
  36. ),
  37.  
  38. ])
  39.  
  40. # описываем логику дашборда
  41. if __name__ == '__main__':
  42. app.run_server(host='0.0.0.0', port=3000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement