Skip to content

Instantly share code, notes, and snippets.

@amitrani6
Created November 22, 2019 04:07

Revisions

  1. amitrani6 created this gist Nov 22, 2019.
    21 changes: 21 additions & 0 deletions plotly_growth_rate_campbell.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Plotly Growth Rate Chart For The Campbell Soup Company

    # Calculate Growth Rate
    cpb['growth_rate'] = cpb['Adj Close'].pct_change()
    s_and_p['growth_rate'] = s_and_p['Adj Close'].pct_change()

    fig = go.Figure()

    # You can add multiple traces, in this case financial securities
    fig.add_trace(go.Scatter(x=cpb.Date, y=cpb['growth_rate'],
    name="Campbell Soup Company", line_color='deepskyblue', hovertext=cpb["Adj Close"]))


    fig.update_layout(title_text='CPB Growth Rates 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()