数据可视化资源

Posted by Zhenda on Mon, Jan 8, 2024
Total Views: 1

dash

官方文档: https://dash.plotly.com/tutorial

streamlit

官方文档: https://docs.streamlit.io/

plotly

官方文档: https://plotly.com/python/getting-started/

demo

1
2
3
4
5
6
7
8
9
import plotly.express as px

fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
# fig = px.pie(x=["a", "b", "c"], y=[1, 3, 2])
# fig = px.line(x=["a", "b", "c"], y=[1, 3, 2])
# fig = px.scatter(x=["a", "b", "c"], y=[1, 3, 2])

fig.show()
# write_html()

subplots demo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(
    rows=2, cols=2,
    specs=[[{"type": "xy"}, {"type": "polar"}],
           [{"type": "domain"}, {"type": "scene"}]],
)

fig.add_trace(go.Bar(y=[2, 3, 1]),
              row=1, col=1)

fig.add_trace(go.Barpolar(theta=[0, 45, 90], r=[2, 3, 1]),
              row=1, col=2)

fig.add_trace(go.Pie(values=[2, 3, 1]),
              row=2, col=1)

fig.add_trace(go.Scatter3d(x=[2, 3, 1], y=[0, 0, 0],
                           z=[0.5, 1, 2], mode="lines"),
              row=2, col=2)

fig.update_layout(height=700, showlegend=False)

fig.show()

matplotlib

官方文档: https://matplotlib.org/stable/index.html