Close Menu
Cryprovideos
    What's Hot

    ‘Battle For Bitcoin,’ Saylor Urges As BTC Struggles At $108,100

    July 5, 2025

    Scammers Drain $70,000 From Financial institution Accounts in Scheme Concentrating on JPMorgan Chase, Financial institution of America, Citibank and Capital One Clients: Report – The Every day Hodl

    July 5, 2025

    Why loyalty is changing into web3 gaming’s subsequent important layer

    July 5, 2025
    Facebook X (Twitter) Instagram
    Cryprovideos
    • Home
    • Crypto News
    • Bitcoin
    • Altcoins
    • Markets
    Cryprovideos
    Home»Markets»Visualizing Inventory Information Quantity with Python Bubble Charts
    Visualizing Inventory Information Quantity with Python Bubble Charts
    Markets

    Visualizing Inventory Information Quantity with Python Bubble Charts

    By Crypto EditorJanuary 28, 2025No Comments3 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Bubble charts are well-suited for three-dimensional information illustration:

    • X-axis: The timeline (e.g., months or years).
    • Y-axis: The frequency or rely of revealed articles.
    • Bubble Dimension: Highlights the magnitude of stories protection for every interval.

    This methodology of visualization helps us determine tendencies, outliers, or important will increase in information quantity which will point out main developments for a inventory. Utilizing Python, we will:

    1. Fetch information information utilizing the Monetary Modeling Prep API.
    2. Course of the information to combination month-to-month article counts.
    3. Create and improve the bubble chart with interactive options.

    By the tip of this tutorial, you’ll have a script that not solely visualizes information quantity but in addition permits for intuitive exploration.

    Guarantee the next Python libraries are put in in your surroundings:

    • requests: For fetching information from APIs.
    • pandas: For information manipulation and aggregation.
    • matplotlib: For creating bubble charts.
    • numpy: For numerical operations like normalization.

    Set up these packages utilizing pip if obligatory:

    pip set up requests pandas matplotlib numpy

    We are going to use the Monetary Modeling Prep API to fetch information articles associated to a given inventory ticker. The API gives article publication dates and related metadata.

    import requests
    import pandas as pd

    # Initialize variables
    ticker = "NVDA" # Substitute along with your most well-liked inventory ticker
    base_url = "https://financialmodelingprep.com/api/v3/stock_news"
    web page = 0
    max_pages = 1500 # Variety of pages to fetch (alter as wanted)
    news_data = []
    api_key = "" # Substitute along with your API key

    # Fetch articles from a number of pages
    whereas web page < max_pages:
    response = requests.get(f"{base_url}?tickers={ticker}&web page={web page}&apikey={api_key}")
    if response.status_code == 200:
    articles = response.json()
    if not articles:
    break # Cease fetching if no articles are returned
    news_data.lengthen(articles)
    web page += 1
    else:
    print(f"Did not fetch information on web page {web page}. HTTP Standing Code: {response.status_code}")
    break

    # Convert the fetched information right into a DataFrame
    df = pd.DataFrame(news_data)

    On this script, we iterate over a number of pages to gather all obtainable articles, making a DataFrame for processing. Remember to change along with your precise API key.

    As soon as now we have the uncooked information, we course of it to extract the publication dates and rely the variety of articles monthly.

    # Convert the 'publishedDate' column to datetime format
    df['publishedDate'] = pd.to_datetime(df['publishedDate'])

    # Extract the 12 months and month from the publication date
    df['YearMonth'] = df['publishedDate'].dt.to_period('M')

    # Depend the variety of articles monthly
    article_counts = df['YearMonth'].value_counts().sort_index()

    This step ensures that our information is grouped and summarized by month. By utilizing the to_period('M') operate, we effectively bucket dates into month-to-month intervals.

    Bubble charts present an intuitive and visually compelling solution to show the aggregated information.

    import matplotlib.pyplot as plt
    import numpy as np

    # Normalize article counts for coloration mapping
    norm = plt.Normalize(article_counts.min(), article_counts.max())
    colours = plt.cm.viridis(norm(article_counts.values))

    # Plot the bubble chart
    fig, ax = plt.subplots(figsize=(12, 8))
    scatter = ax.scatter(
    article_counts.index.astype(str), # Convert index to string for x-axis labels
    article_counts, # Y-axis represents article counts
    s=article_counts * 100, # Bubble dimension scales with article rely
    c=colours, # Shade map for bubbles
    alpha=0.6, # Transparency stage
    cmap='viridis' # Shade map
    )

    # Add a coloration bar to point article quantity
    cbar = plt.colorbar(scatter, ax=ax)
    cbar.set_label('Variety of Articles')

    # Customise the chart look
    ax.set_xlabel('Yr-Month')
    ax.set_ylabel('Variety of Articles')
    ax.set_title(f'Information Quantity Over Time for {ticker}')
    plt.xticks(rotation=45)
    plt.grid(alpha=0.3)

    Enhancing the chart with interactive components gives an enticing expertise for customers. By hovering over bubbles, viewers can see detailed annotations for every information level.

    # Add interactivity to show annotations
    def update_annotation(ind):
    pos = scatter.get_offsets()[ind["ind"][0]]
    annot.xy = pos
    textual content = f"{article_counts.index[ind['ind'][0]]}: {article_counts.iloc[ind['ind'][0]]} articles"
    annot.set_text(textual content)
    annot.get_bbox_patch().set_facecolor('white')
    annot.get_bbox_patch().set_alpha(0.6)

    annot = ax.annotate(
    "",
    xy=(0, 0),
    xytext=(15, 15),
    textcoords="offset factors",
    bbox=dict(boxstyle="spherical", facecolor="white", edgecolor="grey"),
    arrowprops=dict(arrowstyle="->")
    )
    annot.set_visible(False)

    # Join hover performance to the determine
    def on_hover(occasion):
    if occasion.inaxes == ax:
    cont, ind = scatter.comprises(occasion)
    if cont:
    update_annotation(ind)
    annot.set_visible(True)
    fig.canvas.draw_idle()
    else:
    annot.set_visible(False)
    fig.canvas.draw_idle()

    fig.canvas.mpl_connect("motion_notify_event", on_hover)

    When visualized for corporations like NVIDIA (NVDA), Palantir (PLTR), or Hims & Hers Well being (HIMS), the bubble chart reveals:



    Supply hyperlink

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

    Related Posts

    Scammers Drain $70,000 From Financial institution Accounts in Scheme Concentrating on JPMorgan Chase, Financial institution of America, Citibank and Capital One Clients: Report – The Every day Hodl

    July 5, 2025

    Why loyalty is changing into web3 gaming’s subsequent important layer

    July 5, 2025

    BNB Will get Large Backer as Nano Labs Begins Billion-Greenback Accumulation

    July 5, 2025

    Ripple and Tenity Launch XRPL Accelerator to Increase Singapore Blockchain

    July 5, 2025
    Latest Posts

    ‘Battle For Bitcoin,’ Saylor Urges As BTC Struggles At $108,100

    July 5, 2025

    Bitcoin (BTC) Market: Institutional Power Amid Retail Fragility

    July 5, 2025

    Trump's 'Huge Stunning Invoice' Passes—And Bitcoin Might Fall to $90K, Says Arthur Hayes – Decrypt

    July 5, 2025

    Mercado Bitcoin declares tokenization of $200M in RWAs on XRPL

    July 5, 2025

    Whales Energy Bitcoin Money ($BCH) to 8-Month Excessive as Golden Cross Indicators Breakout

    July 5, 2025

    Finest Crypto to Purchase Now as $8.6B Bitcoin Whale Awakens After 14 Years – CryptoDnes EN

    July 5, 2025

    Litecoin Destiny Tied To Bitcoin – Will $96 Resistance Crack?

    July 5, 2025

    Bitcoin Primed To Hit New All-Time Excessive Quickly Sufficient, In response to Constancy’s International Macro Analyst Jurrien Timmer – Right here’s Why – The Day by day Hodl

    July 5, 2025

    CryptoVideos.net is your premier destination for all things cryptocurrency. Our platform provides the latest updates in crypto news, expert price analysis, and valuable insights from top crypto influencers to keep you informed and ahead in the fast-paced world of digital assets. Whether you’re an experienced trader, investor, or just starting in the crypto space, our comprehensive collection of videos and articles covers trending topics, market forecasts, blockchain technology, and more. We aim to simplify complex market movements and provide a trustworthy, user-friendly resource for anyone looking to deepen their understanding of the crypto industry. Stay tuned to CryptoVideos.net to make informed decisions and keep up with emerging trends in the world of cryptocurrency.

    Top Insights

    Crypto Traders HODLing Solana in Anticipation of Larger SOL Costs, In accordance with Analytics Agency – The Day by day Hodl

    December 14, 2024

    Singaporean Crypto Traders Enhance XRP Holdings To 17%, Report Finds

    May 25, 2025

    Analyst Says One Crypto Sector Is Primed To Outperform within the Days Forward – Right here’s His High Choose – The Day by day Hodl

    January 3, 2025

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    • Home
    • Privacy Policy
    • Contact us
    © 2025 CryptoVideos. Designed by MAXBIT.

    Type above and press Enter to search. Press Esc to cancel.