In [13]:
import matplotlib.pyplot as plt
# Data
labels = ['prostate', 'lung & bronchus', 'Colon & rectum', 'Urinary bladder' , 'Melanoma of the skin' , 'Kidney & renal pelvis' , 'Non-Hodgkin lymphoma' , 'Oral cavity & pharynx' , 'Leukemia' , 'Pancreas']
sizes = [29, 11, 8, 6, 6, 5, 4, 4, 4, 3] # Percentages or proportions
# Plot
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
# Make it look good
plt.title('male cancer distribution', fontsize=20)
plt.axis('equal') # Equal aspect ratio makes the pie circular
plt.show()
In [7]:
sizes
Out[7]:
[29, 11, 8, 6, 6, 5, 4, 4, 4, 3]
In [12]:
import matplotlib.pyplot as plt
# Data
labels = ['lung & bronchus', 'prostate', 'Colon & rectum', 'Pancreas' , 'Liver & intrahepatic bile duct' , 'Leukemia' , 'Esophagus' , 'Urinary bladder' , 'Non-Hodgkin lymphoma' , 'Brain & other nervous system']
sizes = [20, 11, 9, 8, 6, 4, 4, 4, 4, 3] # Percentages or proportions
# Plot
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
# Make it look good
plt.title('male rate of deaths', fontsize=20)
plt.axis('equal') # Equal aspect ratio makes the pie circular
plt.show()
In [23]:
# Plot y=x^2
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace (0,2,100)
fig, ax = plt.subplots()
y1 = np.sin(x)
y2 = np.cos(x)
plt.plot(x, y1, label='sin(x)', color='blue')
plt.plot(x, y2, label='cos(x)', color='red')
ax.set_xlabel("x")
ax.set_ylabel("y")
plt.legend()
plt.show()
In [ ]: