Created
November 22, 2019 03:50
-
-
Save amitrani6/f519f9b855b9199cad19245aee0b824a to your computer and use it in GitHub Desktop.
OHLC with Plotly for the Campbell Soup Company
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
# A Plotly OHLC Chart With A Rangeslider | |
# This code is adapted from the Plotly site | |
# Source: https://plot.ly/python/ohlc-charts/ | |
# Import the necessary libraries | |
import pandas as pd | |
import numpy as np | |
# The section of the Plotly library needed | |
import plotly.graph_objects as go | |
# Obtain data from the data frame | |
fig = go.Figure(data=go.Ohlc(x=cpb['Date'], | |
open=cpb['Open'], | |
high=cpb['High'], | |
low=cpb['Low'], | |
close=cpb['Close'])) | |
# Add title and annotations | |
fig.update_layout(title_text='CPB From November 21, 2018 to November 21, 2019', | |
title={ | |
'y':0.9, | |
'x':0.5, | |
'xanchor': 'center', | |
'yanchor': 'top'}, | |
xaxis_rangeslider_visible=True, xaxis_title="Time", yaxis_title="Growth Rate Percentage") | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment