Skip to content

Instantly share code, notes, and snippets.

@russelllim22
Last active August 25, 2021 20:45
Show Gist options
  • Save russelllim22/2562b124fc24ed4f48103b56291a92a9 to your computer and use it in GitHub Desktop.
Save russelllim22/2562b124fc24ed4f48103b56291a92a9 to your computer and use it in GitHub Desktop.
import plotly.graph_objects as go
pub_counts_10.reverse() # reverse order so that largest bar is on top
pub_names_10.reverse() # (Plotly will graph the bottom bar first)
bar_chart = go.Figure(go.Bar(
x = pub_counts_10,
y = pub_names_10,
orientation='h', # horizontal bar chart
marker=dict(
color='rgba(0, 45, 168,0.5)', # style the bars
line=dict(
color='rgba(0, 45, 168,1)',
width=1)
)
))
bar_chart.update_layout(
title= "Math: Top 10 Pubs.",
title_font_family="Arial Black",
title_font_size=30,
title_x=0.5, # center the title
xaxis_title="% of Math articles",
)
bar_chart.write_image("images/math-bar.png") # export the graph as a png file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment