Automationscribe.com
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automation Scribe
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automationscribe.com
No Result
View All Result

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
I discovered a hidden gem in Matplotlib’s library: Packed Bubble Charts in Python | by Anna Gordun Peiro | Jul, 2024
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


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 accommodates occasion to Athlete degree Olympic Video games Outcomes from Athens 1896 to Beijing 2022. After an EDA (Exploratory Knowledge Evaluation) I remodeled it right into a dataset that particulars the variety of feminine athletes in every sport/occasion per yr. 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 beneath:

Display shot of plotting dataset

That is my method to visualise it:

  • Measurement proportion. Utilizing radius of bubbles to match quantity athletes per sport. Greater bubbles will characterize extremely aggressive occasions, similar to Athletics
  • Multi variable interpretation. Making use of colors to characterize feminine illustration. Mild inexperienced bubbles will characterize occasions with a 50/50 break up, similar to Hockey.

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

First consequence

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 straight in dataset

Second consequence

Properly, now not less than it’s readable. However, why is Athletics pink and Boxing blue? Let’s add a legend as an 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 will 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) will probably be
xy = [50, 128]

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

# Add textual content

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

# Mix rectangle and textual content
vbox = HPacker(kids=[da, text], align="high", 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 below the chart simply by utilizing plt.textual content()

Remaining visualisation

Simple and person 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 break 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 by way of athlete quantity (Swimming, Athletics and Gymnastics) are very near having a 50/50 break up
Tags: AnnaBubbleChartsgemGordunhiddenJullibraryMatplotlibsPackedPeiroPython
Previous Post

IBM Analysis Advances Explainable AI with New Instruments and Visualizations

Next Post

AI Boosts Prospects for Expert Staff

Next Post
AI Boosts Prospects for Expert Staff

AI Boosts Prospects for Expert Staff

Leave a Reply Cancel reply

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

Popular News

  • How Aviva constructed a scalable, safe, and dependable MLOps platform utilizing Amazon SageMaker

    How Aviva constructed a scalable, safe, and dependable MLOps platform utilizing Amazon SageMaker

    401 shares
    Share 160 Tweet 100
  • Diffusion Mannequin from Scratch in Pytorch | by Nicholas DiSalvo | Jul, 2024

    401 shares
    Share 160 Tweet 100
  • Unlocking Japanese LLMs with AWS Trainium: Innovators Showcase from the AWS LLM Growth Assist Program

    401 shares
    Share 160 Tweet 100
  • Proton launches ‘Privacy-First’ AI Email Assistant to Compete with Google and Microsoft

    400 shares
    Share 160 Tweet 100
  • Streamlit fairly styled dataframes half 1: utilizing the pandas Styler

    400 shares
    Share 160 Tweet 100

About Us

Automation Scribe is your go-to site for easy-to-understand Artificial Intelligence (AI) articles. Discover insights on AI tools, AI Scribe, and more. Stay updated with the latest advancements in AI technology. Dive into the world of automation with simplified explanations and informative content. Visit us today!

Category

  • AI Scribe
  • AI Tools
  • Artificial Intelligence

Recent Posts

  • Construct an clever neighborhood agent to revolutionize IT assist with Amazon Q Enterprise
  • How To not Write an MCP Server
  • A Evaluate of AccentFold: One of many Most Necessary Papers on African ASR
  • Home
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

© 2024 automationscribe.com. All rights reserved.

No Result
View All Result
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us

© 2024 automationscribe.com. All rights reserved.