42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import plotly.graph_objects as go
|
|
from nicegui import ui
|
|
|
|
fig = go.Figure(go.Scatter(x=[1, 2, 3, 4], y=[1, 2, 3, 2.5]))
|
|
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0))
|
|
|
|
import plotly.express as px
|
|
import pandas
|
|
df = px.data.gapminder()
|
|
df1 = df.query("country == 'United States'")
|
|
|
|
print(df1.columns)
|
|
fig = px.line(df1,
|
|
x="year",
|
|
y="lifeExp",
|
|
# color="continent",
|
|
title="A Plotly Express Figure",
|
|
markers=True,
|
|
# symbol="continent",
|
|
line_shape="linear"
|
|
)
|
|
# ['linear', 'hv', 'vh', 'hvh', 'vhv']
|
|
df2 = df.query("continent == 'Oceania'")
|
|
fig = px.bar(df2,
|
|
x="year",
|
|
y="pop",
|
|
color="country",
|
|
barmode="group"
|
|
)
|
|
ui.plotly(fig)
|
|
|
|
# ui.run()
|
|
|
|
import plotly.graph_objects as go
|
|
from nicegui import ui
|
|
|
|
fig = go.Figure(go.Scatter(x=[1, 2, 3, 4], y=[1, 2, 3, 2.5]))
|
|
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0))
|
|
plot = ui.plotly(fig).classes('w-full h-40')
|
|
plot.on('plotly_click', ui.notify)
|
|
|
|
ui.run() |