An warware: pie auto percentage

A cikin duniyar yau, nazarin bayanai da hangen nesa suna taka muhimmiyar rawa a masana'antu daban-daban, gami da salo. Taswirar kek sanannen hanya ce don wakiltar bayanai cikin sha'awar gani da sauฦ™in fahimta. ฦŠayan shari'ar amfani gama gari ita ce nuna adadin kowane rukuni a cikin saitin bayanai. A cikin wannan labarin, za mu tattauna yadda ake ฦ™irฦ™ira taswirar keษ“aษ“ษ“u ta atomatik ta amfani da Python, da kuma zurfafa cikin ษ—akunan karatu da ayyuka masu alaฦ™a waษ—anda ke taimakawa magance matsalar.

Yayin ฦ™irฦ™irar ginshiฦ™i na kek na atomatik na iya zama kamar aiki mai ban tsoro, ษ—imbin ษ—akunan karatu da ayyuka na Python suna sa wannan tsari ya dace sosai. Maganinmu za ta yi amfani da yaren shirye-shiryen Python da dakunan karatu kamar Matplotlib da NumPy, waษ—anda galibi ana amfani da su don ganin bayanai da ayyukan lambobi.

Bayanin mataki-mataki na Code

Don magance wannan matsalar, za mu bi matakan da aka zayyana a ฦ™asa:

1. Shigo da dakunan karatu na Python (Matplotlib da NumPy)
2. Shirya bayanai don ginshiฦ™i kek
3. ฦ˜ayyade saitunan ginshiฦ™i kuma ฦ™irฦ™irar taswirar kek tare da ฦ™imar kashi ta atomatik
4. Nuna ginshiฦ™i kek

import matplotlib.pyplot as plt
import numpy as np

# Data preparation
categories = ['Trendy', 'Classic', 'Casual', 'Formal', 'Athletic']
values = [25, 35, 15, 10, 15]

# Chart settings and creation
fig, ax = plt.subplots()
ax.pie(values, labels=categories, autopct='%1.1f%%', startangle=90)

# Equal aspect ratio ensures the pie chart is circular
ax.axis('equal')

# Display the pie chart
plt.show()

Mun fara da shigo da dakunan karatu na Python da ake buฦ™ata, Matplotlib da NumPy. To,, muna shirya bayanan don zane-zanen Pial ษ—inmu, ma'anar nau'ikan daban-daban da ฦ™imarsu masu dacewa. A cikin misalinmu, waษ—annan nau'ikan suna wakiltar salon salo daban-daban tare da kaso masu alaฦ™a.

Matplotlib Library

matplotlib yana ษ—aya daga cikin shahararrun ษ—akunan karatu na Python don ganin bayanai. Yana ba da damar ฦ™irฦ™irar adadi mai yawa, irin su layin layi, rarrabuwa, da mashaya, ban da ginshiฦ™an kek. Abin da ya sa Matplotlib ya fice shi ne ikonsa na keษ“ance filaye zuwa matsayi mai girma, gyara kamanninsu, har ma da ฦ™irฦ™irar abubuwan gani na mu'amala.

A cikin lambar mu, muna amfani da aikin โ€œpie()โ€ na Matplotlib don ฦ™irฦ™irar ginshiฦ™i daga bayanan shigarwa. Ana amfani da ma'aunin "autopct" don nuna ฦ™imar ฦ™imar atomatik, yayin da ma'aunin "startangle" yana juya ginshiฦ™i zuwa yanayin da ake so.

Laburaren NumPy

Lambobi (Python na lambobi) wani muhimmin ษ—akin karatu na Python ne, musamman don lissafin lambobi. Yana ba da tallafi don tsararraki, matrices, da ayyuka daban-daban na lissafi, kamar algebra na layi, tsara lambar bazuwar, da ayyukan ฦ™ididdiga. NumPy yana haษ—awa da sauran ษ—akunan karatu na Python kamar Matplotlib, kuma ฦ™arfinsa mai ฦ™arfi ya sa ya zama kayan aiki mai mahimmanci don bincike da sarrafa bayanai.

A cikin misalinmu, ba ma amfani da kowane takamaiman ayyuka na NumPy, amma kasancewar sa yana da mahimmanci ga sauran aikace-aikacen ci-gaba waษ—anda zasu iya ma'amala da sarrafa bayanai masu rikitarwa kafin ฦ™irฦ™irar ginshiฦ™i.

A ฦ™arshe, Python yana ba da madaidaiciyar hanya mai sauฦ™i don ฦ™irฦ™irar taswirar kek na atomatik ta amfani da ษ—akunan karatu kamar Matplotlib da NumPy. Fahimtar wannan tsari ba kawai zai taimaka a ayyukan ganin bayanai ba amma kuma zai inganta ฦ™warewar ku a cikin shirye-shiryen Python da nazarin bayanai gaba ษ—aya.

Shafi posts:

Leave a Comment