当使用 Plotly 进行数据可视化时,我们可以通过以下示例展示多种绘图方法,每个示例都会有详细的注释和说明。
1.创建折线图
import plotly.graph_objects as go # 示例1: 创建简单的折线图 x = [1, 2, 3, 4, 5] y = [10, 15, 13, 17, 20] # 创建折线图 fig = go.Figure(data=go.Scatter(x=x, y=y, mode='lines+markers', name='数据线')) # 设置图形布局 fig.update_layout( title='示例折线图', xaxis_title='X轴标签', yaxis_title='Y轴标签', showlegend=True ) # 显示图形 fig.show()