Skip to content

Instantly share code, notes, and snippets.

@VorontsovIE
Created January 8, 2019 17:57
Show Gist options
  • Save VorontsovIE/7c34bc91a7a559d95b01cb1d9295e379 to your computer and use it in GitHub Desktop.
Save VorontsovIE/7c34bc91a7a559d95b01cb1d9295e379 to your computer and use it in GitHub Desktop.
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode()
x = [8,10,6]
y = ['Kenya', 'Kosovo', 'Nigeria']
y_enum = list(range(len(y)))
worst_score, best_score = 7, 20
overhang = 0.25
bar_width=0.5
best_score_ref= go.Scatter(
mode='lines',
y=[-overhang, len(y) - 1 + overhang],
x = [best_score] * 2,
)
worst_score_ref= go.Scatter(
mode='lines',
y=[-overhang, len(y) - 1 + overhang],
x = [worst_score] * 2,
)
bar=go.Bar(x=x, y=y_enum, orientation='h', width=bar_width)
data=[bar, best_score_ref, worst_score_ref]
layout = go.Layout({'yaxis':{'tickmode': 'array', 'ticktext': y, 'tickvals': y_enum}})
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment