Knowledge Base

Takeaway Sheet: The plotly Library

Practice

1# Plotting an interactive line chart
2
3import plotly.express as px
4
5fig = px.line(data, x='column1', y='column2', title='Plot title')
6fig.show()

1# Rotating the axes' labels
2
3fig.update_xaxes(tickangle=45) # rotate the tick labels on the X axis 45 degrees
4fig.show()

1# Plotting an interactive histogram
2# the color parameter gets its name from the column the data is to be grouped by
3
4import plotly.express as px
5
6fig = px.bar(data, x='column1', y='column2', color='column3', title='Plot title')
7fig.update_xaxes(tickangle=45)
8fig.show()

1# Plotting an interactive pie chart
2# labels - the names of shares
3# values - the values of shares
4
5from plotly import graph_objects as go
6
7fig = go.Figure(data=[go.Pie(labels=labels_series, values=values_series)])
8fig.show()

1# Building an interactive funnel
2# y - the names of funnel stages
3# x - the number of users at the stage
4
5from plotly import graph_objects as go
6
7fig = go.Figure(go.Funnel(y = y_series, x = x_series))
8fig.show()
Send Feedback
close
  • Bug
  • Improvement
  • Feature
Send Feedback
,