Created
February 6, 2021 14:24
-
-
Save FlowerWrong/2d9277bd991eba399876d080f5c2a5ea to your computer and use it in GitHub Desktop.
AAPL stock line chart in python using charthub.cc
This file contains hidden or 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
# 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