{"id":145,"date":"2026-03-02T15:47:03","date_gmt":"2026-03-02T10:47:03","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=145"},"modified":"2026-03-17T08:12:36","modified_gmt":"2026-03-17T03:12:36","slug":"pie-and-histogram","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/","title":{"rendered":"\u00a0Pie and Histogram"},"content":{"rendered":"\n<p>Pie Charts and Histograms are commonly used visualizations in Data Analytics.<br>They help represent proportions and data distributions clearly.<\/p>\n\n\n\n<p>First, import Matplotlib:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import matplotlib.pyplot as plt<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">1. Pie Chart<\/h2>\n\n\n\n<p>A Pie Chart shows the proportion or percentage of categories in a dataset.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Market Share<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">companies = [\"Company A\", \"Company B\", \"Company C\", \"Company D\"]<br>market_share = [40, 25, 20, 15]plt.pie(market_share, labels=companies)<br>plt.title(\"Market Share Distribution\")<br>plt.show()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Adding Percentage Labels<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">plt.pie(market_share, labels=companies, autopct=\"%1.1f%%\")<br>plt.title(\"Market Share Distribution\")<br>plt.show()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Exploding a Slice<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">explode = [0.1, 0, 0, 0]plt.pie(market_share, labels=companies, autopct=\"%1.1f%%\", explode=explode)<br>plt.title(\"Market Share Distribution\")<br>plt.show()<\/pre>\n\n\n\n<p>When to Use Pie Chart:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Showing percentage distribution<\/li>\n\n\n\n<li>Comparing parts of a whole<\/li>\n\n\n\n<li>Presenting simple categorical breakdown<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. Histogram<\/h2>\n\n\n\n<p>A Histogram shows the distribution of numerical data.<\/p>\n\n\n\n<p>It groups values into intervals (bins).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Exam Scores Distribution<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">scores = [55, 60, 65, 70, 75, 80, 85, 90, 95, 60, 70, 80, 85]plt.hist(scores, bins=5)<br>plt.title(\"Exam Score Distribution\")<br>plt.xlabel(\"Scores\")<br>plt.ylabel(\"Frequency\")<br>plt.show()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Adjusting Number of Bins<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">plt.hist(scores, bins=10)<br>plt.title(\"Exam Score Distribution\")<br>plt.show()<\/pre>\n\n\n\n<p>When to Use Histogram:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Understanding data distribution<\/li>\n\n\n\n<li>Detecting skewness<\/li>\n\n\n\n<li>Identifying outliers<\/li>\n\n\n\n<li>Analyzing frequency patterns<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Pie Chart vs Histogram<\/h2>\n\n\n\n<p>Pie Chart:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used for categorical data<\/li>\n\n\n\n<li>Shows proportions<\/li>\n\n\n\n<li>Represents parts of a whole<\/li>\n<\/ul>\n\n\n\n<p>Histogram:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used for numerical data<\/li>\n\n\n\n<li>Shows frequency distribution<\/li>\n\n\n\n<li>Represents data spread<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Key Takeaway<\/h2>\n\n\n\n<p>Pie Charts help visualize proportions of categories, while Histograms help analyze the distribution of numerical data. Both are essential tools for understanding datasets in data analytics.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FOR DATA ANALYTICS (PYDA) > Data Visualization > Pie and Histogram<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773717268566\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":77,"template":"","class_list":["post-145","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u00a0Pie and Histogram - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u00a0Pie and Histogram - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-17T03:12:36+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/pie-and-histogram\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/pie-and-histogram\\\/\",\"name\":\"\u00a0Pie and Histogram - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T10:47:03+00:00\",\"dateModified\":\"2026-03-17T03:12:36+00:00\",\"description\":\"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/pie-and-histogram\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/pie-and-histogram\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/pie-and-histogram\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FOR DATA ANALYTICS (PYDA) > Data Visualization > Pie and Histogram\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u00a0Pie and Histogram - One Language. Endless Possibilities","description":"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/","og_locale":"en_US","og_type":"article","og_title":"\u00a0Pie and Histogram - One Language. Endless Possibilities","og_description":"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.","og_url":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-17T03:12:36+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/","url":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/","name":"\u00a0Pie and Histogram - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T10:47:03+00:00","dateModified":"2026-03-17T03:12:36+00:00","description":"Learn Matplotlib pie charts and histograms in Python to visualize proportions, analyze data distribution, and present insights effectively.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/pie-and-histogram\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FOR DATA ANALYTICS (PYDA) > Data Visualization > Pie and Histogram"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}