Stock Price Distribution with Shade

Suppose you have a dataset showcasing the stock price of a company over time. Visualize a distplot that displays the distribution of prices with a shade under the curve.

Example Output:

Use sns.distplot and set the kde_kws parameter to add shade.

import seaborn as sns
import matplotlib.pyplot as plt

def plot_stock_distribution(prices):
    sns.distplot(prices, kde_kws={"shade": True})
    plt.show()

# This function can be called with a list of stock prices.
# For the sake of this example, let's assume a random list of stock prices.
prices = [100, 101, 103, 105, 106, 107, 108, 110, 109, 108]
plot_stock_distribution(prices)

 

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!