In [30]:
import matplotlib.pyplot as plt
import numpy as np
# Create x values
x = np.linspace(0, 10, 100)
# Define functions
f_x = x**2
g_x = np.sqrt(x)
# Plot both functions with different styles
plt.figure(figsize=(8,6))
plt.plot(x, f_x, label='f(x) = x²', color='blue', linestyle='-') # Line plot
plt.scatter(x, g_x, label='g(x) = √x', color='red', marker='o') # Scatter plot
# Add labels and legend
plt.xlabel('x')
plt.ylabel('y')
plt.title('Plot of Two Functions with Different Styles')
plt.legend()
plt.grid(True)
plt.show()
In [31]:
import matplotlib.pyplot as plt
import numpy as np
# Create x values
x = np.linspace(0, 10, 100)
f_x = x**2
g_x = np.sqrt(x)
# Create side-by-side subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 5)) # 1 row, 2 columns
# First plot: f(x) = x^2
axs[0].plot(x, f_x, color='blue', label='f(x) = x²')
axs[0].set_title('Line Plot of f(x) = x²')
axs[0].set_xlabel('x'),
axs[0].set_ylabel('y')
axs[0].grid(True)
axs[0].legend()
# Second plot: g(x) = √x
axs[1].scatter(x, g_x, color='red', label='g(x) = √x')
axs[1].set_title('Scatter Plot of g(x) = √x')
axs[1].set_xlabel('x')
axs[1].set_ylabel('y')
axs[1].grid(True)
axs[1].legend()
# Display both plots
plt.tight_layout()
plt.show()
In [32]:
import pandas as pd
import openpyxl
import matplotlib.pyplot as plt
# Load the Excel File
cancer_cases=pd.read_excel(r"C:\Users\keysc\Downloads\Cancer_Cases_deaths_2025.xlsx", engine='openpyxl')
# Clean column names
cancer_cases.columns = cancer_cases.columns.str.strip()
# Replace'_' with Na and convert to numeric
cancer_cases['Estimated New Cases 2025'] = cancer_cases['Estimated New Cases 2025'].replace('-', pd.NA)
# Drop rows with missing values
cancer_cases = cancer_cases.dropna(subset=['Estimated New Cases 2025'])
# Convert to float
cancer_cases['Estimated New Cases 2025'] = cancer_cases['Estimated New Cases 2025'].astype(float)
# Replace 'Cancer type' and Cases with your actual column names
labels = cancer_cases['Common Type of Cancers']
sizes = cancer_cases['Estimated New Cases 2025']
# Plot the pie chart
plt.figure(figsize=(8,8))
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
plt.title('Estimated New Cancers Cases in 2025')
plt.axis('equal') # Ensures pie is drawn in a circle
plt.show()
#Preview the cleaned data
print(cancer_cases.head())
Unnamed: 0 Rank Common Type of Cancers Estimated New Cases 2025 \ 0 NaN 1.0 Breast Cancer (Female) 316950.0 1 NaN 2.0 Prostate Cancer 313780.0 2 NaN 3.0 Lung and Bronchus Cancer 226650.0 3 NaN 4.0 Colorectal Cancer 154270.0 4 NaN 5.0 Melanoma of the Skin 104960.0 Estimated Deaths 2025 0 42170 1 35770 2 124730 3 52900 4 8430
In [33]:
# Bar graph of Estimated New Cancer Cases
plt.figure(figsize=(10,6))
plt.bar(labels, sizes, color='skyblue')
plt.xticks(rotation=45, ha='right')
plt.ylabel('Number of Cases')
plt.title('Estimated New Cancer Cases in 2025')
plt.tight_layout()
plt.show()