Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
601 B
0
Indexable
Never
import matplotlib.pyplot as plt

# Data
conditions = ['Pneumonia', 'Bronchitis', 'Asthma', 'Tuberculosis', 'Flu', 'Common Colds', 'Sore Throat']
respondents = [6, 1, 10, 7, 8, 17, 13]
total_respondents = 40

# Calculate percentages
percentages = [(r / total_respondents) * 100 for r in respondents]

# Create bar graph
plt.figure(figsize=(10, 6))
plt.barh(conditions, percentages, color='skyblue')
plt.xlabel('Percentage of Respondents (%)')
plt.title('Percentage of Respondents for Different Conditions')
plt.gca().invert_yaxis()  # Invert y-axis to have the highest percentage at the top
plt.show()
Leave a Comment