LAB: Data Visualization
ลิ้งเนื้อหา Data Visualization
ติดตั้ง Library สำหรับ Data Visualization
pip install pywebio
pip install pandas
pip install plotlyGet start with pywebio
# A simple script to calculate BMI
import pywebio
import plotly.express as px
import pandas as pd
from pywebio.input import input, FLOAT
from pywebio.output import put_text, put_html, put_markdown, put_table
def page():
height = input("Input your height(cm):", type=FLOAT)
weight = input("Input your weight(kg):", type=FLOAT)
BMI = weight / (height / 100) ** 2
top_status = [(16, 'Severely underweight'), (18.5, 'Underweight'),
(25, 'Normal'), (30, 'Overweight'),
(35, 'Moderately obese'), (float('inf'), 'Severely obese')]
for top, status in top_status:
if BMI <= top:
put_markdown('# **Results**')
put_text('Your BMI: %.1f. Category: %s' % (BMI, status))
put_html('<br><br>')
put_markdown('Your BMI: `%.1f`. Category: `%s`' % (BMI, status))
put_html('<hr>')
put_table([
['Your BMI', 'Category'],
[BMI, status],
])
break
html = fig.to_html(include_plotlyjs="require", full_html=False) #convert your figure to html format
put_html(html)
if __name__ == '__main__':
pywebio.start_server(page, port=80) #local default port is 80
Plot bar graph
Show your CSV in the table
Plot graph with a CSV file
Last updated
Was this helpful?