• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
Tuesday, July 15, 2025
newsaiworld
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
Morning News
No Result
View All Result
Home Artificial Intelligence

I discovered a hidden gem in Matplotlib’s library: Packed Bubble Charts in Python | by Anna Gordun Peiro | Jul, 2024

Admin by Admin
July 28, 2024
in Artificial Intelligence
0
1s6vkcd3s72mhxci4qskywq.png
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

READ ALSO

What Can the Historical past of Knowledge Inform Us Concerning the Way forward for AI?

Easy Information to Multi-Armed Bandits: A Key Idea Earlier than Reinforcement Studying


For my chart, I’m utilizing an Olympic Historic Dataset from Olympedia.org which Joseph Cheng shared in Kaggle with a public area license.

Screenshot of dataset

It comprises occasion to Athlete degree Olympic Video games Outcomes from Athens 1896 to Beijing 2022. After an EDA (Exploratory Information Evaluation) I remodeled it right into a dataset that particulars the variety of feminine athletes in every sport/occasion per 12 months. My bubble chart concept is to point out which sports activities have a 50/50 feminine to male ratio athletes and the way it has advanced throughout time.

My plotting knowledge consists of two completely different datasets, one for annually: 2020 and 1996. For every dataset I’ve computed the whole sum of athletes that participated to every occasion (athlete_sum) and the way a lot that sum represents in comparison with the variety of whole athletes (male + feminine) (distinction). See a screenshot of the info under:

Display shot of plotting dataset

That is my method to visualise it:

  • Dimension proportion. Utilizing radius of bubbles to check quantity athletes per sport. Larger bubbles will symbolize extremely aggressive occasions, akin to Athletics
  • Multi variable interpretation. Making use of colors to symbolize feminine illustration. Mild inexperienced bubbles will symbolize occasions with a 50/50 cut up, akin to Hockey.

Right here is my start line (utilizing the code and method from above):

First end result

Some simple fixes: growing determine dimension and altering labels to empty if the scale isn’t over 250 to keep away from having phrases exterior bubbles.

fig, ax = plt.subplots(figsize=(12,8),subplot_kw=dict(side="equal"))

#Labels edited instantly in dataset

Second end result

Properly, now not less than it’s readable. However, why is Athletics pink and Boxing blue? Let’s add a legend for instance the connection between colors and feminine illustration.

As a result of it’s not your common barplot chart, plt.legend() doesn’t do the trick right here.

Utilizing matplotlib Annotation Bbox we will create rectangles (or circles) to point out which means behind every color. We are able to additionally do the identical factor to point out a bubble scale.

import matplotlib.pyplot as plt
from matplotlib.offsetbox import (AnnotationBbox, DrawingArea,
TextArea,HPacker)
from matplotlib.patches import Circle,Rectangle

# That is an instance for one part of the legend

# Outline the place the annotation (legend) shall be
xy = [50, 128]

# Create your coloured rectangle or circle
da = DrawingArea(20, 20, 0, 0)
p = Rectangle((10 ,10),10,10,shade="#fc8d62ff")
da.add_artist(p)

# Add textual content

textual content = TextArea("20%", textprops=dict(shade="#fc8d62ff", dimension=14,fontweight='daring'))

# Mix rectangle and textual content
vbox = HPacker(kids=[da, text], align="prime", pad=0, sep=3)

# Annotate each in a field (change alpha if you wish to see the field)
ab = AnnotationBbox(vbox, xy,
xybox=(1.005, xy[1]),
xycoords='knowledge',
boxcoords=("axes fraction", "knowledge"),
box_alignment=(0.2, 0.5),
bboxprops=dict(alpha=0)
)
#Add to your bubble chart
ax.add_artist(ab)

I’ve additionally added a subtitle and a textual content description underneath the chart simply through the use of plt.textual content()

Ultimate visualisation

Simple and consumer pleasant interpretations of the graph:

  • Majority of bubbles are mild inexperienced → inexperienced means 50% females → majority of Olympic competitions have a good 50/50 feminine to male cut up (yay🙌)
  • Just one sport (Baseball), in darkish inexperienced color, has no feminine participation.
  • 3 sports activities have solely feminine participation however the variety of athletes is pretty low.
  • The largest sports activities when it comes to athlete quantity (Swimming, Athletics and Gymnastics) are very near having a 50/50 cut up
Tags: AnnaBubbleChartsgemGordunhiddenJulLibraryMatplotlibsPackedPeiroPython

Related Posts

Screenshot 2025 07 10 at 10.28.48 pm 1.png
Artificial Intelligence

What Can the Historical past of Knowledge Inform Us Concerning the Way forward for AI?

July 15, 2025
Before reinforcement learning understand the multi armed bandit.png
Artificial Intelligence

Easy Information to Multi-Armed Bandits: A Key Idea Earlier than Reinforcement Studying

July 14, 2025
Image 126 scaled 1.png
Artificial Intelligence

Recap of all forms of LLM Brokers

July 14, 2025
1.webp.webp
Artificial Intelligence

The Essential Position of NUMA Consciousness in Excessive-Efficiency Deep Studying

July 13, 2025
Chatgpt image jul 8 2025 07 17 39 pm.png
Artificial Intelligence

Analysis-Pushed Growth for LLM-Powered Merchandise: Classes from Constructing in Healthcare

July 12, 2025
Data mining 3 hanna barakat aixdesign archival images of ai 3328x2312.png
Artificial Intelligence

Hitchhiker’s Information to RAG: From Tiny Information to Tolstoy with OpenAI’s API and LangChain

July 12, 2025
Next Post
How cultural differences impact sentiment analysis feature.jpg

How Cultural Variations Influence Sentiment Evaluation

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

POPULAR NEWS

0 3.png

College endowments be a part of crypto rush, boosting meme cash like Meme Index

February 10, 2025
Gemini 2.0 Fash Vs Gpt 4o.webp.webp

Gemini 2.0 Flash vs GPT 4o: Which is Higher?

January 19, 2025
1da3lz S3h Cujupuolbtvw.png

Scaling Statistics: Incremental Customary Deviation in SQL with dbt | by Yuval Gorchover | Jan, 2025

January 2, 2025
How To Maintain Data Quality In The Supply Chain Feature.jpg

Find out how to Preserve Knowledge High quality within the Provide Chain

September 8, 2024
0khns0 Djocjfzxyr.jpeg

Constructing Data Graphs with LLM Graph Transformer | by Tomaz Bratanic | Nov, 2024

November 5, 2024

EDITOR'S PICK

Shutterstock ai agent.jpg

AI agent startup based by ex-Google DeepMinder • The Register

July 15, 2025
1726810210 Ai Data Storage Shutterstock 1107715973 Special.jpg

At 2024 AI {Hardware} & Edge AI Summit: Vasudev Lal, Principal AI Analysis Scientist, Cognitive AI, Intel Labs

September 20, 2024
0hubmquumfv8xozlx.jpeg

Influential Time-Sequence Forecasting Papers of 2023–2024: Half 1 | by Nikos Kafritsas | Jan, 2025

January 17, 2025
1crb3ihxfsn4sk6zuqmsknw.jpeg

Why Ratios Trump Uncooked Numbers in Enterprise Well being | by Shirley Bao, Ph.D. | Sep, 2024

September 6, 2024

About Us

Welcome to News AI World, your go-to source for the latest in artificial intelligence news and developments. Our mission is to deliver comprehensive and insightful coverage of the rapidly evolving AI landscape, keeping you informed about breakthroughs, trends, and the transformative impact of AI technologies across industries.

Categories

  • Artificial Intelligence
  • ChatGPT
  • Crypto Coins
  • Data Science
  • Machine Learning

Recent Posts

  • Report: 87% of Corporations Use AI Instruments in App Growth Processes
  • Accuracy Is Lifeless: Calibration, Discrimination, and Different Metrics You Really Want
  • James Wynn Returns with $19M Bitcoin, $100k PEPE Guess
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy

© 2024 Newsaiworld.com. All rights reserved.

No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us

© 2024 Newsaiworld.com. All rights reserved.

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?