Created
May 25, 2022 10:38
-
-
Save kristjan-eljand/748657f8d8d562d27e688b0cf65bc6aa to your computer and use it in GitHub Desktop.
Making barchart with plotly graph objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly | |
import plotly.graph_objects as go | |
x = pd.Series({0:2020, 1:2021, 2:2022}) | |
y = pd.Series({0: 10, 1:20, 2:30}) | |
fig = go.Figure() | |
fig.add_trace(go.Bar(x = x, y = y)) | |
fig.update_traces( | |
marker_color='rgb(68, 84, 106)', | |
marker_line_width=0, | |
yaxis=None) | |
# https://plotly.com/python/configuration-options/ | |
# https://plotly.com/python/reference/layout/ | |
fig.update_layout( | |
plot_bgcolor = "rgba(0,0,0,0)", | |
modebar_remove = ["zoomOutMapbox", "zoomin", "zoomout"], | |
) | |
# https://plotly.com/python/reference/layout/yaxis/ | |
fig.update_yaxes( | |
showticklabels = False | |
) | |
graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment