Skip to content
Activities · Activity 4.3

Q.Plot a pie to display the radius of the planets and also give an appropriate title to the plot.
[Context: The referenced textbook DataFrame (Program 4-16) is df = pd.DataFrame({'mass': [0.330, 4.87, 5.97], 'radius': [2439.7, 6051.8, 6378.1]}, index=['Mercury', 'Venus', 'Earth']).]

Puducherry CbseNCERTSubjective· 3mImportance★★★★★est
14% · 6/44 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

A pie chart is inappropriate for displaying planetary radii because pie charts show parts of a whole (proportions that sum to 100%), not absolute measurements. A bar chart is the correct choice, but the question asks for a pie chart, so we demonstrate both the requested (incorrect) plot and the proper alternative.

Why a pie chart is the wrong tool here

A pie chart divides a circle into slices whose areas represent proportions of a total. It answers "what fraction of the whole does each category represent?" For example, if you had the market share of three companies (30%, 50%, 20%), a pie chart makes sense because those percentages sum to 100%.

Planetary radii are absolute measurements in kilometers. Mercury's radius of 2439.7 km is not "a fraction of the total radius of all planets"—that total is a meaningless sum. The radius of Earth is not "37% of something"; it is simply 6378.1 km. Plotting these values as a pie chart forces the viewer to interpret slices as proportions when no such proportion exists in the data.

The textbook question likely intends to teach the syntax of pie charts in pandas/matplotlib, even though the semantic choice is flawed. We will produce the requested pie chart, then show the correct visualization.


The requested (incorrect) pie chart

import pandas as pd
import matplotlib.pyplot as plt

# Given DataFrame
df = pd.DataFrame({
    'mass': [0.330, 4.87, 5.97],
    'radius': [2439.7, 6051.8, 6378.1]
}, index=['Mercury', 'Venus', 'Earth'])

# Plot pie chart of radius
df['radius'].plot(kind='pie', autopct='%1.1f%%', startangle=90, figsize=(6, 6))
plt.title('Radius of Planets (Inappropriate Pie Chart)')
plt.ylabel('')  # Remove the default 'radius' label on the y-axis
plt.show()

What this produces:

  • A pie chart with three slices labeled Mercury, Venus, and Earth.
  • Each slice shows a percentage: Mercury ≈16.4%, Venus ≈40.7%, Earth ≈42.9% (these are the radii divided by their sum, 14869.6 km).
  • The percentages are meaningless—they do not represent any real-world proportion.
  • Title: "Radius of Planets (Inappropriate Pie Chart)".
Watch out

The autopct='%1.1f%%' parameter displays percentages on each slice. These percentages are calculated as (radius / sum_of_all_radii) × 100, which has no physical interpretation. A viewer might mistakenly think Earth is "43% of the planets" in some sense, when in fact it is simply 6378.1 km in radius.

Key lines explained:

  • df['radius'].plot(kind='pie', ...) — pandas' .plot() method with kind='pie' creates a pie chart from the Series. Each index label (planet name) becomes a slice.
  • autopct='%1.1f%%' — formats the percentage labels to one decimal place.
  • startangle=90 — rotates the chart so the first slice starts at the top (12 o'clock position), a common convention.
  • plt.ylabel('') — the default pie chart adds a y-axis label equal to the column name ('radius'); we remove it for clarity.

The correct visualization: a bar chart

# Correct plot: bar chart
df['radius'].plot(kind='bar', color='steelblue', edgecolor='black')
plt.title('Radius of Planets')
plt.xlabel('Planet')
plt.ylabel('Radius (km)')
plt.xticks(rotation=0)
plt.grid(axis='y', linestyle='--', alpha=0.6)
plt.tight_layout()
plt.show()

What this produces: …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.