Create Horizontal Barchart
Tags: #plotly #chart #horizontalbar #dataviz #snippet #operations #image #html
Learn more on the Plotly doc : https://plotly.com/python/horizontal-bar-charts/
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)
Last modified 3mo ago