Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Created March 7, 2022 00:57
Show Gist options
  • Select an option

  • Save audhiaprilliant/78f925b7033996f3c72c868b4fce08a2 to your computer and use it in GitHub Desktop.

Select an option

Save audhiaprilliant/78f925b7033996f3c72c868b4fce08a2 to your computer and use it in GitHub Desktop.
Introduction to Plotly
# 4 Set a bar width
# Create list of bar width
widths = np.repeat(0.5, len(df))
# Create object of figure
fig = go.Figure()
# Create a bar plot
fig.add_trace(
go.Bar(
x = df['Fruit'],
y = df['Sales'],
width = widths
)
)
# Config for title, background, legend etc
fig.update_layout(
plot_bgcolor = 'white',
font = {
'color': '#797979'
}
)
# Show graph
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment