Template request | Bug report | Generate Data Product
Tags: #plotly #chart #horizontalbar #dataviz #snippet #operations #image #html
Author: Florent Ravenel
Description: This notebook provides instructions on how to create a horizontal bar chart using Plotly.
import plotly.graph_objects as go
fig = go.Figure(
go.Bar(
x=[20, 14, 23],
y=["giraffes", "orangutans", "monkeys"],
orientation="h",
text=[20, 14, 23],
)
)
fig.update_layout(
title="Horizontal barchart",
plot_bgcolor="#ffffff",
width=1200,
height=800,
margin_pad=10,
xaxis_showticklabels=False,
bargap=0.1, # gap between bars of adjacent location coordinates.
bargroupgap=0.2, # gap between bars of the same location coordinate.
)
config = {"displayModeBar": False}
fig.show(config=config)
fig.write_image(output_image, width=1200)
fig.write_html(output_html)
link_image = naas.asset.add(output_image)
link_html = naas.asset.add(output_html, {"inline": True})
# -> Uncomment the line below to remove your assets
# naas.asset.delete(output_image)
# naas.asset.delete(output_html)