Skip to content

Instantly share code, notes, and snippets.

@FlowerWrong
Created February 6, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FlowerWrong/2d9277bd991eba399876d080f5c2a5ea to your computer and use it in GitHub Desktop.
Save FlowerWrong/2d9277bd991eba399876d080f5c2a5ea to your computer and use it in GitHub Desktop.
AAPL stock line chart in python using charthub.cc
# demo code
import plotly.express as px
import plotly.io as pio
import akshare as ak
pio.templates.default = "none"
df = ak.stock_us_daily(symbol='AAPL', adjust='qfq')
df = df.loc['2015-01-01':'2022-01-01']
df = df.reset_index()
fig = px.line(df, x="date", y="close", title='AAPL stock line chart',
labels={
"date": "date",
"close": "close price($)"
}, render_mode="svg")
fig.update_xaxes(tickformat="%Y-%m-%d")
fig.update_layout(dragmode='pan', autosize=True)
fig.update_traces(line_color='royalblue', line_width=2)
# you should always write figure json to this file -> figure.json
f = open("figure.json", "w")
f.write(fig.to_json())
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment