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.